[dba-Tech] VBS question

Susan Harkins ssharkins at gmail.com
Fri Jun 21 09:00:59 CDT 2019


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