-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRefresher Sample.vbs
More file actions
29 lines (22 loc) · 950 Bytes
/
Copy pathRefresher Sample.vbs
File metadata and controls
29 lines (22 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
' sample of a VBscript that can be scheduled e.g. in Windows Tasks Scheduler
'Samples of call VBS from .bat or command prompt
' Refresher.vbs /TargetFilePath:"C:\Temp\Test.xlsm"
' Refresher.vbs /TargetFilePath:"C:\Temp\BOA Automation\Sample with 2 DS.xlsb"
Set NamedArguments = WScript.Arguments.Named
if not NamedArguments.Exists("TargetFilePath") then
TargetFilePath = "C:\Temp\BOA Automation\Sample with 2 DS.xlsb"
else
TargetFilePath = NamedArguments("TargetFilePath")
end if
set xlapp = CreateObject("Excel.Application")
xlapp.visible = true
xlapp.workbooks.open TargetFilePath ', true, true
' run macro "Refresh" located in worksheet ControlPanel (ID of worksheet, NOT a name)
if xlapp.Run("ControlPanel.Refresh") = 0 then
WScript.Echo "Refresh Failed"
end if
xlapp.Quit
' not 100% stable method
' used only for demo purpose
' Better solution can be found here
' https://github.com/IvanBond/Power-Refresh