{1st post}
Many thanks to all of you who have helped me in the past, however no amount of searching has given me a solution to this one, so I'm posting in the hope that someone can point out where I'm going wrong...
I need a module in Access which:
1- runs a few queries, placing the outputs into an excel file,
2- renames the worksheets
3- saves document as a new file name (incorporating today's date)
so far i can achieve one and two, but I've had no luck with 3...
the relevant bit of code is:
the ActiveWorkbook.SaveAs bit works fine if I run the code as a macro within excel, however when i put it into the Access module I get the following error:
"Object doesn't support this property or method"
I've tried all sorts of odds and ends I've dug up from the internet without success - I'm new into IT and have never used VBA before, so I'm winging it somewhat...
Any ideas or assistance would be gratefully received!
Many thanks to all of you who have helped me in the past, however no amount of searching has given me a solution to this one, so I'm posting in the hope that someone can point out where I'm going wrong...
I need a module in Access which:
1- runs a few queries, placing the outputs into an excel file,
2- renames the worksheets
3- saves document as a new file name (incorporating today's date)
so far i can achieve one and two, but I've had no luck with 3...
the relevant bit of code is:
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("C:\M08_09\Reporting\LIVEDOC - Open.xls")
objXLApp.Application.Visible = True
objXLBook.Sheets("Sub_Q_IMPART_OpenCases_Alloc_BD").Name = "BD-Allocated"
{... cut more of the same sheet-renaming code ...}
objXLBook.ActiveWorkbook.SaveAs Filename:= _
"C:\M08_09\Reporting\Open Cases - " & Format(Date, "yyyy.mm.dd") & ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
the ActiveWorkbook.SaveAs bit works fine if I run the code as a macro within excel, however when i put it into the Access module I get the following error:
"Object doesn't support this property or method"
I've tried all sorts of odds and ends I've dug up from the internet without success - I'm new into IT and have never used VBA before, so I'm winging it somewhat...
Any ideas or assistance would be gratefully received!
Last edited: