J
Jules Hoppenbrouwers
In short I'd like a MS Project macro to copy the result of a query in
an MS Excel worksheet. I must admit that that VBA is quite new for me.
Manually the proces goes as follows:
1. I save the project as a Pivot Table
2. I run the Linked Table Manager in MS Access that gets the data from
three worksheets that where created in step 1.
3. The result of the quiry is copied (from MS Access) and must be
pasted in an other MS Excel worksheet.
These are the problems that I encounter:
ad 1. When I run Linked Table Manager from the Project VBA as follows:
strDB = "c:\myAccessDB.mdb"
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDB
DoCmd.RunCommand acCmdLinkedTableManager 'Opens the Linked Table
Manager
Everytime you run the Linked Table Manager from the macro a new copy
is created from the Linked Excel Tables. Of course I can make a delete
statements which deletes the copy afterwards, but is this the way it
should be done?
ad 3. I don't seem to be able to actually copy the results from the
Access query as I would manually. This is how I do it manually;
In de object pane I select Queries. Then open my quiry which will show
me the results of the Linked Table Manager action. I select all rows
and I paste them in my Excel document. Their must be a way to fit this
in a macro. Can anybody tell me how?
To conclude I'd like to add that I also tried the
DoCmd.TransferSpreadsheet (DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel8, "Task overview", "export.xls"). But this
leaves me with an Excel spreatsheet where some columns are not
included and others are relocated to somewhere else on this sheet.
an MS Excel worksheet. I must admit that that VBA is quite new for me.
Manually the proces goes as follows:
1. I save the project as a Pivot Table
2. I run the Linked Table Manager in MS Access that gets the data from
three worksheets that where created in step 1.
3. The result of the quiry is copied (from MS Access) and must be
pasted in an other MS Excel worksheet.
These are the problems that I encounter:
ad 1. When I run Linked Table Manager from the Project VBA as follows:
strDB = "c:\myAccessDB.mdb"
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDB
DoCmd.RunCommand acCmdLinkedTableManager 'Opens the Linked Table
Manager
Everytime you run the Linked Table Manager from the macro a new copy
is created from the Linked Excel Tables. Of course I can make a delete
statements which deletes the copy afterwards, but is this the way it
should be done?
ad 3. I don't seem to be able to actually copy the results from the
Access query as I would manually. This is how I do it manually;
In de object pane I select Queries. Then open my quiry which will show
me the results of the Linked Table Manager action. I select all rows
and I paste them in my Excel document. Their must be a way to fit this
in a macro. Can anybody tell me how?
To conclude I'd like to add that I also tried the
DoCmd.TransferSpreadsheet (DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel8, "Task overview", "export.xls"). But this
leaves me with an Excel spreatsheet where some columns are not
included and others are relocated to somewhere else on this sheet.