Jim Young
2011-04-28 20:04:50 UTC
I've looked around these news groups and, since I am a complete noob
in VBscripting, most of it was way over my head. So here's my
question in a nutshell.
I tested the macro being referenced in the below script within Excel
itself and it works fine. However, when I call the macro using the VB
script below, it doesn't wait for the macro to complete (it takes
about 5 minutes as the macro is pulling from an Essbase cube) - it
just plows forward through the rest of the macro (which, after pulling
the information, saves the workbook) and then through the rest of the
VB script
Is there a way to force the VBscript to wait while the Excel macro
finishes on its own?
Set exapp = CreateObject("Excel.Application")
exapp.visible = true
exapp.Application.DisplayAlerts = False 'eliminates any alerts or
warnings
exapp.Application.AskToUpdateLinks = false
exapp.workbooks.Open ("C:\Documents and Settings\Jim\Desktop\2011
Rack Daily-MTD-YTD Sales.xls")
exapp.run "DoAll" (FYI THIS MACRO IS ACTALLY CALLING SEVERAL MACROS
- AND IT WORKS FINE IN EXCEL)
' exapp.activeworkbook.save
exapp.Application.DisplayAlerts = False 'eliminates any alerts or
warnings
exapp.activeworkbook.close true
exapp.quit
set exapp = nothing
in VBscripting, most of it was way over my head. So here's my
question in a nutshell.
I tested the macro being referenced in the below script within Excel
itself and it works fine. However, when I call the macro using the VB
script below, it doesn't wait for the macro to complete (it takes
about 5 minutes as the macro is pulling from an Essbase cube) - it
just plows forward through the rest of the macro (which, after pulling
the information, saves the workbook) and then through the rest of the
VB script
Is there a way to force the VBscript to wait while the Excel macro
finishes on its own?
Set exapp = CreateObject("Excel.Application")
exapp.visible = true
exapp.Application.DisplayAlerts = False 'eliminates any alerts or
warnings
exapp.Application.AskToUpdateLinks = false
exapp.workbooks.Open ("C:\Documents and Settings\Jim\Desktop\2011
Rack Daily-MTD-YTD Sales.xls")
exapp.run "DoAll" (FYI THIS MACRO IS ACTALLY CALLING SEVERAL MACROS
- AND IT WORKS FINE IN EXCEL)
' exapp.activeworkbook.save
exapp.Application.DisplayAlerts = False 'eliminates any alerts or
warnings
exapp.activeworkbook.close true
exapp.quit
set exapp = nothing