[dba-Tech] VBS question
Gustav Brock
gustav at cactus.dk
Fri Jun 21 09:16:27 CDT 2019
Hi Susan
It could be that it doesn't run using your account.
Try moving the script and workbook to the Shared/Public Documents folder.
/gustav
-----Oprindelig meddelelse-----
Fra: dba-Tech <dba-tech-bounces at databaseadvisors.com> På vegne af Susan Harkins
Sendt: 21. juni 2019 16:01
Til: 'Discussion of Hardware and Software issues' <dba-tech at databaseadvisors.com>
Emne: Re: [dba-Tech] VBS question
Thanks Gustav -- still not working.
I dropped in a cell(1,"A").Value = Time() statement just test and it doesn't work either -- the script is running -- I can see the Echo on the screen.
Not sure how to continue troubleshooting.
Is it possible that it's something with my Task Scheduler settings?
The Action is Start a program.
The Program/script is C:\Windows\Systems32\cscript.exe.
The only argment is "C:\Users\Susan Harkins\Documents\PrintPivotTable.vbs"
I have the visible property set to True and I thought I would see Excel quickly open, but that doesn't happen. Should it?
Susan H.
tech at databaseadvisors.com>
Subject: Re: [dba-Tech] VBS question
Hi Susan
Excel is very picky with its objects. So, try:
'.vbs file to print Excel PivoTable1.xlsm at 8am daily.
'Path to workbook.
strPath = "C:\Documents\PivotTable1.xlsm"
'Macro name.
strMacro = "PrintUpdatedPivotTable"
'Create an Excel instance.
Set objApp = CreateObject("Excel.Application") Set objwb =
objExcel.Workbooks.Open(strPath) objApp.Visible = True ' Should not be needed.
objApp.Run strMacro
objwb.Close
Set objwb = Nothing
objApp.Quit
Set objApp = Nothing
'Scheduled task completed.
MsgBox strPath & " " & strMacro & " PivotTable printed successfully", vbInformation
Also, check that no Excel instance is left open after running the script.
More information about the dba-Tech
mailing list