alsoascientist
Registered User.
- Local time
- Today, 21:57
- Joined
- Mar 26, 2012
- Messages
- 39
Hi All,
I have set up a code that will export information from a query based on conditions described by functions within the code and I am now trying to take hold of Excel (the information is exported to there)and format the data.
I have seen a coulpe of ideas kicking about on the net but they all opening the database at the start - mine is already open. I also have the issue that the file name (workbook name) will be set by the user on export, so I don't have the option to close and then re-open.
I have this so far, and I am getting the error "automation error, invalid syntax"
Any ideas / advice?
I have set up a code that will export information from a query based on conditions described by functions within the code and I am now trying to take hold of Excel (the information is exported to there)and format the data.
I have seen a coulpe of ideas kicking about on the net but they all opening the database at the start - mine is already open. I also have the issue that the file name (workbook name) will be set by the user on export, so I don't have the option to close and then re-open.
I have this so far, and I am getting the error "automation error, invalid syntax"
Code:
'Export code is in here...
DoCmd.OutputTo acOutputQuery, "qryTemp", acFormatXLS, , True
Dim ObjExcel
Dim ObjSheet
Set ObjExcel = GetObject(Excel.Application)'this is where the error happens
ObjExcel.Visible = True
Set ObjSheet = ObjExcel.ActiveWorkbook.Worksheets("qryTemp")
With ObjSheet
ActiveWindow.DisplayGridlines = False
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.ColorIndex = 11
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
'there is a lot more formatting code but it didn't see the use in putting it here too
Any ideas / advice?