weatherman85
New Member
- Joined
- Feb 26, 2016
- Messages
- 5
I've tried looking around to an answer to this but I haven't been able to find anything that actually resolves it for me.
I am trying to use Excel to run TransferSpreadsheet for a series of queries that are determined by a range in Excel. When I put the code in Access, I have no problems running it. When I try to translate it back to Excel I get two different run time errors.
The first happens when the file isn't there: Err 3011. If I create a blank file with the name of the export I then get Err 3073.
Seeing as how it works from Access, I really can't see why it wouldn't work from Excel. Then again, if I could see why I'd know the answer....
Any help would be appreciated.
I am trying to use Excel to run TransferSpreadsheet for a series of queries that are determined by a range in Excel. When I put the code in Access, I have no problems running it. When I try to translate it back to Excel I get two different run time errors.
The first happens when the file isn't there: Err 3011. If I create a blank file with the name of the export I then get Err 3073.
Seeing as how it works from Access, I really can't see why it wouldn't work from Excel. Then again, if I could see why I'd know the answer....
Any help would be appreciated.
Code:
Dim objAccess As Object, dbase, export As Range
Dim wkb As Workbook, wks As Worksheet
Set objAccess = CreateObject("Access.Application")
Set wkb = ActiveWorkbook
Set wks = wkb.Worksheets("Sheet1")
Set dbase = wks.Range("D8")
Set export = wks.Range("D10")
With objAccess
.Visible = False
.OpenCurrentDatabase (dbase & "test.accdb")
.Visible = False
.DoCmd.TransferSpreadsheet acExport, 10, "qry1", export & "qry1.xlsx", True
End With