I need to refresh my Excel-workbook with 2 worksheets from Access and save it a to a different file name to be picked up by an Outlook Email Task schedule.
Part 1 getting the Excel updated:
My plan is to having XP Scheduled Task to open the Workbook with a Macro named Auto_Open to do the refreshes and that Marco to save the Workbook as a non-Macro spreadsheet.
Part 2:
Then have an Outlook task to email the non-Macro Excel workbook out. Then another XP Scheduled Task scheduled task to delete the non-Macro Excel workbook for the next night the process goes again.
Part 1 is having problems:
The refresh all on open was working but I needed to get the Excel saved without the Refresh on open process. So, I added a Save As non-marco notebook into the Marco.
Then Excel was giving me the message on the save as part of the macro:
"This action will cancel a pending Refresh Data command.".
So, broke apart the refreshes to refresh one workbook then the next; I am now getting the message:
"Object variable or with block variable not set"
Sub Auto_Open()
'
' Auto_Open Macro
'
'
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("2010 Tracking Database 5500").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Key").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\neumar1\My Documents\PART1refreshMarco.xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Any help on a process improvement or fix to the current approach will be appreciated.
Thx
Russ
Bookmarks