Question Locked

set window size in vbscript

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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
Mike

5 replies

by robo_dev

This should work for WSH or VBS, I believe:

1) set wshshell=createobject("wscript.shell")

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 wshShell.run object: the value of 3 means maximized.

http://msdn.microsoft.com/en-us/library/d5fk67ky%28VS.85%29.aspx

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

http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

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:

/A "=OpenActions" ""

For example:

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

by mslamen

robo_dev
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
Mike

by robo_dev

I'm pretty sure you can just call the filename from the wshshell.run 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

http://msdn.microsoft.com/en-us/library/d5fk67ky%28VS.85%29.aspx

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).

http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf

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

by mslamen

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

Thank you for your experstise.

This discussion is closed to new replies.