set window size in vbscript

By mslamen ·
I have a script that opens a .pdf file on the users machine at startup. How can I set the size of the .pdf so that it always opens the same size. (see the script below)

Dim LaunchDir, FSO, WSHShell, strPDFFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
If FSO.FileExists("\\Server-HQ\PUBLIC\SCRIPT\goal.pdf") Then
strPDFFile = "\\server-hq\public\script\goal.pdf"
strPDFFile = Chr(34) & strPDFFile & Chr(34)
wSHShell.Run strPDFFile
End If

Thank you in advance

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

The way I would do it

by robo_dev In reply to set window size in vbscri ...

This should work for WSH or VBS, I believe:

1) set wshshell=createobject("")

2) wshShell.Run """D:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe""""d:\test.pdf""",3

3) set wshshell=nothing

the number at the end of line 2 sets the intwindowstyle parameter for the object: the value of 3 means maximized.

There is also a way to do this with the PDF open parameters, but the syntax can get tricky in VBS.

It's easy in a DOS batch file:
"D:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /A "zoom=1000" "d:\test.pdf"

When opening a PDF document from a command shell, you can pass the parameters to the open command using the /A switch using the following syntax:

<path to Acrobat> /A "<open parameter>=OpenActions" "<path to PDF file>"

For example:

Acrobat.exe /A "zoom=1000=OpenActions" "C:\example.pdf"

Collapse -

All clients would need to be on the same version

by mslamen In reply to The way I would do it

I had a feeling that I would have to enter the version of adobe reader the client has. If you dont wnat maximized, I assume you enter a 2 or 1.

Thank you very much

Collapse -

There are 100 ways to do this....

by robo_dev In reply to All clients would need to ...

I'm pretty sure you can just call the filename from the command if the file association is correct on the Windows machine.

(However I'm not sure if the window-size parameters will get passed using that method).

The link below has a listing of the values for IntWindowStyle

2 is minimized, 1 is the same as the last time it opened.

Not sure if Acrobat window sizes follow the size of the document itself or not.

The PDF open parameters may be more useful since you can set zoom level, turn off scrollbars, and even set the page in the PDF to open. Note that some parameters are not available at the command line ( and therefore not in VBS).

I am pretty sure that the same open parameters would work if they were part of a Windows shortcut.

Collapse -

Open Parameters

by mslamen In reply to There are 100 ways to do ...

like you sais is probably the easiest way to accomplish what I want.

Thank you for your experstise.

Related Discussions

Related Forums