The Save As dialog cannot be automated using VBScript in WSH.

There are at least three problems with this dialog when using ExecWB.

1. The dialog will always be visible and require intervention of the user:
OLECMDEXECOPT_DONTPROMPTUSER is broken and does nothing.

2. The path to the file is in all circumstances ignored. You may as well
use NULL.

3. There is no way to change the file type to be saved. The only input
parameter is supposed to be for the file name and path, which as I said is
completely broken. The only way to get a dialog with all applicable file
types present is by using OLECMDEXECOPT_DONTPROMPTUSER.

Here is my code.
Sub MHT_Save()
'TODO: Remove hard-coded file path
'OLECMDID_SAVEAS = 4 (from MSDN "OLECMDID" topic)
'Also OLECMDEXECOPT_DONTPROMPTUSER = 2
'Save the file using InternetExplorer.Application ExecWB method
App.ExecWB _
OLECMDID_SAVEAS, _
OLECMDEXECOPT_DODEFAULT, _
"C:\\Documents and Settings\\quell\\Desktop\\MHT Project\\MHT File
Output", _
NULL
WScript.Echo("Saving file...")
WScript.Echo(Now())
Do While App.ReadyState <> READYSTATE_COMPLETE
WScript.sleep(1000)
Loop
state = SAVED
End Sub

Re: Save As Dialog Can't be Automated - ExecWB by Steven

Steven
Thu Apr 29 22:27:56 CDT 2004

I know this is VB code, but ..... should give you a little help ;o)

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=51351&ln
gWId=1

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

WebGrid - www.webgrid.co.uk
Freeware Arena - www.freewarearena.com
Freeware Home - www.freewarehome.com
Pricelessware - http://www.pricelessware.org
Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar


"Coy" <w.osborne@comcast.net> wrote in message
news:#3CseAmLEHA.3664@TK2MSFTNGP10.phx.gbl...
> The Save As dialog cannot be automated using VBScript in WSH.
>
> There are at least three problems with this dialog when using ExecWB.
>
> 1. The dialog will always be visible and require intervention of the
user:
> OLECMDEXECOPT_DONTPROMPTUSER is broken and does nothing.
>
> 2. The path to the file is in all circumstances ignored. You may as well
> use NULL.
>
> 3. There is no way to change the file type to be saved. The only input
> parameter is supposed to be for the file name and path, which as I said is
> completely broken. The only way to get a dialog with all applicable file
> types present is by using OLECMDEXECOPT_DONTPROMPTUSER.
>
> Here is my code.
> Sub MHT_Save()
> 'TODO: Remove hard-coded file path
> 'OLECMDID_SAVEAS = 4 (from MSDN "OLECMDID" topic)
> 'Also OLECMDEXECOPT_DONTPROMPTUSER = 2
> 'Save the file using InternetExplorer.Application ExecWB method
> App.ExecWB _
> OLECMDID_SAVEAS, _
> OLECMDEXECOPT_DODEFAULT, _
> "C:\\Documents and Settings\\quell\\Desktop\\MHT Project\\MHT File
> Output", _
> NULL
> WScript.Echo("Saving file...")
> WScript.Echo(Now())
> Do While App.ReadyState <> READYSTATE_COMPLETE
> WScript.sleep(1000)
> Loop
> state = SAVED
> End Sub
>
>
>
>
>



Re: Save As Dialog Can't be Automated - ExecWB by Dave

Dave
Fri Apr 30 00:31:40 CDT 2004

This may help you.

-----------------------
Option Explicit
Dim filePath, oExcel, oSheet

filePath = "c:\Test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Add
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
oSheet.Name = "Some Sheet Name"
oSheet.Cells(1, 1) = "Hello"
oSheet.Cells(1, 2) = "World"
oExcel.ActiveWorkbook.SaveAs filePath
oExcel.ActiveWorkbook.Close
set oSheet = Nothing
Set oExcel = Nothing
-----------------------

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"Coy" wrote:
| The Save As dialog cannot be automated using VBScript in WSH.
|
| There are at least three problems with this dialog when using ExecWB.
|
| 1. The dialog will always be visible and require intervention of the
user:
| OLECMDEXECOPT_DONTPROMPTUSER is broken and does nothing.
|
| 2. The path to the file is in all circumstances ignored. You may as well
| use NULL.
|
| 3. There is no way to change the file type to be saved. The only input
| parameter is supposed to be for the file name and path, which as I said is
| completely broken. The only way to get a dialog with all applicable file
| types present is by using OLECMDEXECOPT_DONTPROMPTUSER.
|
| Here is my code.
| Sub MHT_Save()
| 'TODO: Remove hard-coded file path
| 'OLECMDID_SAVEAS = 4 (from MSDN "OLECMDID" topic)
| 'Also OLECMDEXECOPT_DONTPROMPTUSER = 2
| 'Save the file using InternetExplorer.Application ExecWB method
| App.ExecWB _
| OLECMDID_SAVEAS, _
| OLECMDEXECOPT_DODEFAULT, _
| "C:\\Documents and Settings\\quell\\Desktop\\MHT Project\\MHT File
| Output", _
| NULL
| WScript.Echo("Saving file...")
| WScript.Echo(Now())
| Do While App.ReadyState <> READYSTATE_COMPLETE
| WScript.sleep(1000)
| Loop
| state = SAVED
| End Sub
|
|
|
|
|