Hello All,
I'm trying to copy data from a table in Excel 2007 that is linked to a query in Access 2007 into another worksheet. If I open the file using Excel, it doesn't seem to have a problem. If I use VBA, and open this file from an Access 2007 database, then it gives me a 1004 runtime error, and tells me that the copy method failed.
Here is my code.
It's driving me bananas, that this only happens when it's opened from Access 2007.
Any help will be greatly appreciated.
I'm trying to copy data from a table in Excel 2007 that is linked to a query in Access 2007 into another worksheet. If I open the file using Excel, it doesn't seem to have a problem. If I use VBA, and open this file from an Access 2007 database, then it gives me a 1004 runtime error, and tells me that the copy method failed.
Here is my code.
Code:
Sheets("Data").Range("database1.accdb[#Headers").Copy
Sheets("Data1").Range("A3").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Sheets("Data").Range("database1.accdb").Copy
Sheets("Data1").Range("A4").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Sheets("Data").Range("database1.accdb").AutoFilter
It's driving me bananas, that this only happens when it's opened from Access 2007.
Any help will be greatly appreciated.