VBscript Application.Printout options not working.

I'm not a VB programmer but found a script that I'm trying to modify and execute.
On the .Application.Prinout line if any options are appended it fails with a compliation error with the message Expected Statement and code 800A0400.  If I try it without any options it will execute.  Are options allowed with this method?
Below is the code.

TIa,
Dan
Option Explicit
 
Dim objDoc, objFile, objFSO, objWord, strFile, strPDF, myFile
 
myFile = "C:\Documents and Settings\Administrator\My Documents\adr.doc"	
 
' Create a File System object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
 
' Create a Word object
Set objWord = CreateObject( "Word.Application" )
 
With objWord
	' True: make Word visible; False: invisible
	.Visible = True
 
	' Check if the Word document exists
	If objFSO.FileExists( myFile ) Then
		Set objFile = objFSO.GetFile( myFile )
		strFile = objFile.Path
	Else
		WScript.Echo "FILE OPEN ERROR: The file does not exist" & vbCrLf
		' Close Word
		.Quit
		'Exit Sub
		'Exit
	End If
 
	' Build the fully qualified PDF file name
	strPDF = objFSO.BuildPath( objFile.ParentFolder, _
	         objFSO.GetBaseName( objFile ) & ".pdf" )
 
	' Open the Word document
	.Documents.Open strFile
 
	' Make the opened file the active document
	Set objDoc = .ActiveDocument
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	.ActivePrinter = "CutePDF Writer" 
 
	.Application.Printout _
		FileName:=strFile, Range:=wdPrintAllDocument, Item:= _
		wdPrintDocumentContent, Copies:=1, Pages:="", _
		PageType:=wdPrintAllPage, Collate:=True, Background:=False, _
		PrinttoFile:=False, OutputFileName:=strPDF
			
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	' Close the active document
	objDoc.Close
 
	' Close Word
	.Quit
End With

Open in new window

Dan KaibAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

qz8dswCommented:
what options are you trying to add?
It looks like your converting word documents to PDF.
You can do that in office 2007 with the Office Add-in: Save as PDF but I'm assuming you don't have office 2007.
0
Dan KaibAuthor Commented:
Thanks for the reply,

I do not have Office 2007.

The options I want to use are as follows:

.Application.Printout _
            FileName:=strFile, Range:=wdPrintAllDocument, Item:= _
            wdPrintDocumentContent, Copies:=1, Pages:="", _
            PageType:=wdPrintAllPage, Collate:=True, Background:=False, _
            PrinttoFile:=False, OutputFileName:=strPDF
0
qz8dswCommented:
Those options seem to be standard for using Adobe Distiller or word 2007, but Cute PDF and it's virtual printer I don't know if it supports those options.
I'm assuming you have the developers version of cutePDF.
Going by what I've read on http://www.cutepdf.com/Solutions/ cutepdf does not seem to be supported via vba.
Since you seem to have a developers version and I cannot test any vba changes under cutepdf the only advice I can give you is to contact the cutepdf support at http://www.cutepdf.com/support/Request.asp

But if you don't want to contact support since you can not use any parameters and it works, you could TRY and work through and see if any parameter will work by changing your code to do it one parameter at a time.
Before you go that far you should check on the cutepdf site and make sure you have the latest version of cutepdf.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Dan KaibAuthor Commented:
Thanks for the reply,

I did not realize that the options would be printer specific.  I've recorded some macros and they produce the same options, so I just figured it would be good to go.

I will check with cutepdf support.  I've also tried win2pdf which is similar to cutepdf and it fails the same way.

Thanks for you help, I appreciate it,
Dan
0
qz8dswCommented:
I'd like to see you recordings if possible.
0
Dan KaibAuthor Commented:
Here is the macro created in Word, when it executes it prompts for the file name which is not what I want but you can see the options that it created:

Sub Macro2()
    ActivePrinter = "CutePDF Writer"
    Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
End Sub

What I am trying to do is print the Word document as a PDF from a VBscript where I can name the PDF files on the fly.

Thanks,
Dan
0
qz8dswCommented:
Hi Dan,

Well the difference between the 2 that I can see is , OutputFileName:=strPDF and with cutepdf you have Background:=True as opposed to Background:=False in your original code.

Also cutepdf is adding PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0

It might be any of them, but there is a possibility cutepdf does not support the OutputFilename being specified like that. All you can do is play around and see which one is causing you the grief.

Cheers,
Terry
0
Dan KaibAuthor Commented:
Hi Terry,

Thanks for the reply.  I don't think any options work when trying it from within a VBscript.

On the .Application.Prinout line if any options are appended it fails with a compliation error with the message Expected Statement and code 800A0400.

I tried it with all the same options as the macro and still get the compiliation error.  There is no option that I apply to the command that does not give me the compilation error above.

I found different software WIN2PDF that interfaces with the WIN32 API but it has to run from a VB program not a VBscript.  

Thanks for all of your help, I appreciate it.
Dan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.