Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Printing a document to a file - Newbie

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61373
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Printing a document to a file - Newbie
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Printing a document to a file - Newbie - 6/15/2008 10:00:28 AM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Hi I am trying to print a document to file via a pdf converter, can you please help me with the syntax, I am not able to print.

strPrinterPath = "CutePDF Writer"
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter strPrinterPath

str = "c:\test.doc"

Set objShell = CreateObject("Shell.Application")

objShell.ShellExecute str, "", "", "print", 1
 
 
Post #: 1
 
 RE: Printing a document to a file - Newbie - 6/16/2008 12:05:40 AM   
  ebgreen


Posts: 5041
Score: 31
Joined: 7/12/2005
Status: offline
What happens? Do you get an error? What is the error?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to navmiester)
 
 
Post #: 2
 
 RE: Printing a document to a file - Newbie - 6/16/2008 9:59:08 AM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
It just doesnt do anything.  I have pieced this code from various websites I was wondering if it was possible to make it work.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Printing a document to a file - Newbie - 6/16/2008 11:01:30 AM   
  dm_4ever


Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
If you had the PDF Writer set as the default printer and you selected the document > right clicked > selected print > would this work if you did it manually?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to navmiester)
 
 
Post #: 4
 
 RE: Printing a document to a file - Newbie - 6/16/2008 1:13:30 PM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Yes it should, It works if I manually print the document, however I would like to automate the process without creating a Microsoft word object in VB script

< Message edited by navmiester -- 6/16/2008 1:34:51 PM >

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Printing a document to a file - Newbie - 6/16/2008 1:34:07 PM   
  dm_4ever


Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Have you tried something like this


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to navmiester)
 
 
Post #: 6
 
 RE: Printing a document to a file - Newbie - 6/16/2008 1:48:13 PM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Yes it works, Is it possible to print a word document to file?  I tried the following code with a .doc but it didnt work.  I want to print a document to file however I dont have microsoft word.  I only have Microsoft word viewer

(in reply to dm_4ever)
 
 
Post #: 7
 
 RE: Printing a document to a file - Newbie - 6/16/2008 1:58:32 PM   
  dm_4ever


Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
I've never tried Microsoft Word viewer so I'm not sure....I saw a document that stated that the word viewer did not support printing via a command line so it may not be possible at all.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to navmiester)
 
 
Post #: 8
 
 RE: Printing a document to a file - Newbie - 6/16/2008 2:15:15 PM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
You are right the /p switch is not supported in word from version 97 up.

Two questions

Is it possible to do this via a VB script?

Is it possible to print a document which has already been opened via Word Viewer via VB script?

< Message edited by navmiester -- 6/16/2008 2:29:47 PM >

(in reply to dm_4ever)
 
 
Post #: 9
 
 RE: Printing a document to a file - Newbie - 6/17/2008 7:09:02 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
This switch /mFilePrintDefault
prints word documents via command line in word 2003. I cant check word viewer. Give it a try.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to navmiester)
 
 
Post #: 10
 
 RE: Printing a document to a file - Newbie - 6/17/2008 9:21:24 AM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Hi thanks for that, it works for Word but not for Word Viewer, Is it possible to print via to from Word Viewer via a VB script?

< Message edited by navmiester -- 6/17/2008 9:37:05 AM >

(in reply to Rischip)
 
 
Post #: 11
 
 RE: Printing a document to a file - Newbie - 6/23/2008 1:59:11 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Here's a command which claims to work. DDE_run.exe -s Wordview -t System -n "C:\PROGRA~1\MICROS~2\OFFICE11\WORDVIEW.EXE /n /dde" -c "[REM _DDE_Direct][FileOpen(\"WordDocument.doc\")]"

It requires a third party tool to open and use Word Viewer as a DDE Server.
Info can be found here.
Scroll all the way to the bottom of the page.

http://www.robvanderwoude.com/ddecommandline.html

Have you Tried this ?


      

< Message edited by Rischip -- 6/23/2008 2:35:52 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to navmiester)
 
 
Post #: 12
 
 RE: Printing a document to a file - Newbie - 6/23/2008 3:49:37 PM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
  Thanks alot!

It looks like I still need word installed in order to get the script to print files.  Very nice script though.  I am currently looking into the DDE commands.

< Message edited by navmiester -- 6/23/2008 4:51:02 PM >

(in reply to Rischip)
 
 
Post #: 13
 
 RE: Printing a document to a file - Newbie - 6/24/2008 4:02:14 PM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Even with DDE it only prints with Microsoft Word, not with Word Viewer, any more script ideas?

(in reply to navmiester)
 
 
Post #: 14
 
 RE: Printing a document to a file - Newbie - 6/25/2008 10:24:29 AM   
  navmiester

 

Posts: 10
Score: 0
Joined: 6/15/2008
Status: offline
Does anyone know where the Word.Application object is stored?

(in reply to navmiester)
 
 
Post #: 15
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Printing a document to a file - Newbie Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts