[dba-Tech] VBS question
Daniel Waters
df.waters at outlook.com
Fri Jun 21 08:16:50 CDT 2019
Hi Susan,
I don't work with VBS, but the logic in the script looks right.
2 questions? Is the VBS script actually able to call the macro? Could you run the printer from the VBS script manually?
Also - it might just be syntax where you need to use the actual name of the macro in double quotes instead of a variable name.
Good Luck!
Dan
-----Original Message-----
From: dba-Tech [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Susan Harkins
Sent: June 21, 2019 8:08
To: Discussion of Hardware and Software issues
Subject: [dba-Tech] VBS question
Do any of you use .vbs scripts to interact with an Excel workbook? I've
written one to run from Windows Task Scheduler. It simply triggers a print
macro (prints a PivotTable) daily.
The macro in Excel works. The task is running, but the PivotTable never
prints. This is rather new to me, so I'm sure it's a simple fix, probably in
one of the referencing statements. Can someone take a look? I've tried
several variations of referencing the macro.
'.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
objApp.Run strMacro
objwb.Close
objApp.Quit
'Scheduled task completed.
MsgBox strPath & " " & strMacro & " PivotTable printed successfully",
vbInformation
Susan H.
_______________________________________________
dba-Tech mailing list
dba-Tech at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-tech
Website: http://www.databaseadvisors.com
More information about the dba-Tech
mailing list