Troulbe printing to PDF via VBS script

G

gilbert_jeffd

Hi,

I have a created a simple VBS script that I call from a SQR program in
PeopleSoft. The script executes the Visio OrgChart Wizard and after it
is done building the orgchart, it saves the chart to a unique file name
(userid concatinated with datetime). Another PeopleSoft process then
picks up the file and emails it to the user.

This all works fine.

Now I have been asked to automate the the saving of the orgchart to
PDF.

I recorded a macro from within Visio that gave me the following code:

Application.ActiveDocument.PrintOut PrintRange:=visPrintAll, _
PrinterName:="Adobe PDF"

I have tried to incorporate this code into my script without success.
Here is what I have:

bunch of wizard stuff OutPutFile=FileName

oVisio.ActiveDocument.SaveAs(OutputFile)
oVisio.ActiveDocument.PrintOut 'PrintRange:=visPrintAll,PrinterName
PrinterName:="Adobe PDF"'

oVisio.ActiveDocument.close
oVisio.quit

Set oVisio = nothing

The error I get is: Wrong number of arguements or invalid property
assignment

Visio 2003, Windows 2000 Pro

Very knew to visio and VB so any help would be greatly appreciated.

TIA,

Jeff
 
A

Al Edlund

well if you compare the working one

Application.ActiveDocument.PrintOut PrintRange:=visPrintAll, _
PrinterName:="Adobe PDF"


with

oVisio.ActiveDocument.PrintOut 'PrintRange:=visPrintAll,PrinterName
PrinterName:="Adobe PDF"'

you will note the failing one has an apostrophe in front of printrange and
printername twice....

al
 
G

gilbert_jeffd

Thanks Al,

But the working code is a macro run from within Visio.. if I place that
code as is into my script, it doesnt compile. The single qoutes seem
to be the only way I can even get the code to execute from the script.
 
A

Al Edlund

the single quote in vb is used to flag a comment that isn't to be compiled
(if my memory serves me correctly), thus it would mask the fact that you
still have printername in there twice when it should only be in there once.
your internal macro uses the underscore as a line extension.
al
 
P

priyasane

Al said:
*the single quote in vb is used to flag a comment that isn't to be
compiled
(if my memory serves me correctly), thus it would mask the fact that
you
still have printername in there twice when it should only be in there
once.
your internal macro uses the underscore as a line extension.
al
 
A

Al Edlund

vbs, vba, vb6, and vb.net although sharing the same "visual basic" name have
many differences, so writing code in one does not guarantee it will always
work in one of the others.
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top