Hi, my first post, I am trying to get a script together that will
Open an 03, 07 or 10 excel application, all on the same PC, passing into the script file and version.
Then I perform some operations and leave it open so another automation tool may interact with it and closed the app ala Alt-F4.
however, the objExcel.DisplayAlerts = False does not work, as I am still prompted on shutdown if I want to save.
code:
...
FileName = WScript.Arguments.Item(0)
XLVersion = WScript.Arguments.Item(1)
if XLVersion = 11 then
XLPath = """C:\Program Files\Microsoft Office\Office11\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 12 then
XLPath = """C:\Program Files\Microsoft Office\Office12\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 13 then
XLPath = """C:\Program Files\Microsoft Office\Office13\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 14 then
XLPath = """C:\Program Files\Microsoft Office\Office14\Excel.exe"" "& "/automation -Embedding"
else
XLPath = """C:\Program Files\Microsoft Office\Office12\Excel.exe"" "& "/automation -Embedding"
end if
set oWSH = CreateObject("WScript.Shell")
Ret = oWSH.Run(XLPath, 1, False)
Set objExcel = GetObject("","Excel.Application")
objExcel.Visible = TRUE
objExcel.WindowState = xlMaximized
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.Open(FileName)
---after this, i basically load an addin, then perform some operations to change zoom levels, maximize window, turn off cleartype... and final line of the vbs is
set objExcel = Nothing
---I've tested the value of objExcel.DisplayAlerts and it says False, but when I close Excel, I still get the popup. Ideas? Am I missing something? thank you in advance!
Open an 03, 07 or 10 excel application, all on the same PC, passing into the script file and version.
Then I perform some operations and leave it open so another automation tool may interact with it and closed the app ala Alt-F4.
however, the objExcel.DisplayAlerts = False does not work, as I am still prompted on shutdown if I want to save.
code:
...
FileName = WScript.Arguments.Item(0)
XLVersion = WScript.Arguments.Item(1)
if XLVersion = 11 then
XLPath = """C:\Program Files\Microsoft Office\Office11\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 12 then
XLPath = """C:\Program Files\Microsoft Office\Office12\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 13 then
XLPath = """C:\Program Files\Microsoft Office\Office13\Excel.exe"" "& "/automation -Embedding"
elseif XLVersion = 14 then
XLPath = """C:\Program Files\Microsoft Office\Office14\Excel.exe"" "& "/automation -Embedding"
else
XLPath = """C:\Program Files\Microsoft Office\Office12\Excel.exe"" "& "/automation -Embedding"
end if
set oWSH = CreateObject("WScript.Shell")
Ret = oWSH.Run(XLPath, 1, False)
Set objExcel = GetObject("","Excel.Application")
objExcel.Visible = TRUE
objExcel.WindowState = xlMaximized
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.Open(FileName)
---after this, i basically load an addin, then perform some operations to change zoom levels, maximize window, turn off cleartype... and final line of the vbs is
set objExcel = Nothing
---I've tested the value of objExcel.DisplayAlerts and it says False, but when I close Excel, I still get the popup. Ideas? Am I missing something? thank you in advance!