Hi there,

I have a simple script here:

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("Z:\MyFolder\MyFile.doc")
objDoc.PrintOut()
objDoc.Saved = TRUE
objWord.Quit

And my default printer is set to "Adobe PDF" in order to automatically
generate a "MyFile.pdf" PDF file into my "Z:\MyFolder\" folder.
Everything is ok, but there is no way to configure the Adobe PDF
virtual printer to say to him: ok guy, don't prompt for a file name,
just save the new file as "Myfile.pdf"...

So, when i run my script, a prompt window appears to confirm that the
new pdf file name will be "MyFile.pdf". The answer will always be Yes.

My question is:
Is there a way to run this script (or wsh version) where all possible
(and unwaited) prompts would be "automatically" clicked with default
button?

Thanks

num GG

Re: Automating default button clicking when something is prompted by mr_unreliable

mr_unreliable
Tue Apr 10 11:17:28 CDT 2007

hi Num,

I thought "savechanges" took care of this (i.e., automagically
answering "yes").

Const wdSaveChanges = -1

oDoc.Close wdSaveChanges ' close word and clean up...
oWD.Quit wdSaveChanges

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


num_gg@laposte.net wrote:
> Hi there,
>
> I have a simple script here:
>
> Set objWord = CreateObject("Word.Application")
> Set objDoc = objWord.Documents.Open("Z:\MyFolder\MyFile.doc")
> objDoc.PrintOut()
> objDoc.Saved = TRUE
> objWord.Quit
>
> And my default printer is set to "Adobe PDF" in order to automatically
> generate a "MyFile.pdf" PDF file into my "Z:\MyFolder\" folder.
> Everything is ok, but there is no way to configure the Adobe PDF
> virtual printer to say to him: ok guy, don't prompt for a file name,
> just save the new file as "Myfile.pdf"...
>
> So, when i run my script, a prompt window appears to confirm that the
> new pdf file name will be "MyFile.pdf". The answer will always be Yes.
>
> My question is:
> Is there a way to run this script (or wsh version) where all possible
> (and unwaited) prompts would be "automatically" clicked with default
> button?
>
> Thanks
>
> num GG
>

Re: Automating default button clicking when something is prompted when a vbs script is executing by num_gg

num_gg
Wed Apr 11 05:36:04 CDT 2007

> I thought "savechanges" took care of this (i.e., automagically
> answering "yes").
>
> Const wdSaveChanges = -1
>
> oDoc.Close wdSaveChanges ' close word and clean up...
> oWD.Quit wdSaveChanges
>
Hi JW

I tried this but it doesn't work;
<SAMPLE>********************************************************************
Const wdSaveChanges = -1

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("Z:\MyFolder\MyFile.doc")

objDoc.PrintOut()
objDoc.Close wdSaveChanges ' close word and clean up...
objWord.Quit wdSaveChanges
</
SAMPLE>********************************************************************

Any idea? Can you provide me a full sample?

Cheers

Num



Re: Automating default button clicking when something is prompted when a vbs script is executing by num_gg

num_gg
Thu Apr 12 10:07:32 CDT 2007

To close this thread, I finally find a "stopgap solution" to my
problem:

1=B0/ "Adobe PDF" as default printer,
2=B0/ "Adobe PDF" configured to produce PDFs always in the same folder
(eg:c:\TempPDF)
3=B0/ C#.NET routine to launch the virtual file printing of all the
office files of a given folder (eg: Z:\MyFolder) which produces the
PDF into c:\TempPDF.
4=B0/ When pdf are generated, simply move programmatically (still in
the c#.net routine) the files into the original folder: Z:\MyFolder
5=B0/ By this way, I can iterate on all the folders I want and get my
pdfs into the folders I want.

Thanks to all for your help

Num

PS: For 3=B0/ here's the key sample code to launch the virtual printing
in order to generate the pdf (given points 1=B0/ and 2=B0/):

for (int i =3D 0; i < lstFilesFound.SelectedItems.Count; i++)
{
object fileName =3D lstFilesFound.SelectedItems[i];
string sFullFileName =3D (string)fileName;
ProcessStartInfo psi =3D new ProcessStartInfo();
psi.Verb =3D "print";
psi.CreateNoWindow =3D false;
psi.WindowStyle =3D ProcessWindowStyle.Hidden;
psi.FileName =3D sFullFileName;
psi.UseShellExecute =3D true;
Process.Start(psi);
// Then follows some logging and exception handling stuff...
}