|
-
Jan 20th, 2007, 05:17 AM
#1
Thread Starter
Fanatic Member
PDFCreator
Hi
I want to write a VB6 code that automatically converts word document into PDF format
Here's my code but it doesn't work
VB Code:
Private Sub Command1_Click()
Dim cPDFCreator As clsPDFCreator
Dim PDFName As String
Dim PDFPath As String
Set cPDFCreator = New clsPDFCreator
Set cPDFCreatorOptions = New clsPDFCreatorOptions
Set cPDFCreator.cOptions = cPDFCreatorOptions
'Am storing default printer to restore it later
strDefaultPrinter = Printer.DeviceName
If cPDFCreator.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "Error!"
Exit Sub
End If
With cPDFCreator
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = "C:\PDFTEST\test"
.cOption("AutosaveFilename") = "Description du service.pdf"
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cSaveOptions
.cClearCache
.cPrinterStop = False
.cDefaultPrinter = "PDFCreator"
.cPrintFile "C:\PDFTEST\Description du service.doc"
End With
Printer.Print
Set cPDFCreator = Nothing
Set cPDFCreatorOptions = Nothing
End Sub
Can anyone help me
thanks
-
Feb 18th, 2008, 11:58 PM
#2
Hyperactive Member
Re: PDFCreator
Strangely just looking into this after our printing department decided they would really really rather have pdf than doc. Strangely still have to use the doc to merge approx 1300 forms
First question, did you make a reference to PDFCreator in your project? Just working through it at the moment, so asking the easy questions first.
-
Feb 19th, 2008, 12:31 AM
#3
Hyperactive Member
Re: PDFCreator
OKay got it to work creating a single document, recursive calls aren't working so figure I've change the state of something.
Note this is in a sub as need to send a bunch of documents to it each time I run the overall project. A bit of tidy up on the declarations required I think.
Code:
Private Sub GeneratePDF(ByVal sDocument As String, ByVal sValue As String)
'
Dim cConverter As clsPDFCreator
Dim cConverterOptions As clsPDFCreatorOptions
'
Set cConverter = New clsPDFCreator
Set cConverterOptions = New clsPDFCreatorOptions
Set cConverter.cOptions = cConverterOptions
'
' Check we can initialise Converter
'
If cConverter.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't Initiase PDF Converter", vbCritical, "Letter Generation Error"
Exit Sub
End If
'
With cConverter
.cOption("UseAutoSave") = 1
.cOption("UseAutoSaveDirectory") = 1
.cOption("AutoSaveDirectory") = sNewFolder
.cOption("AutoSaveFileName") = sValue & ".pdf"
.cOption("AutoSaveFormat") = 0 ' 0 = pdf
.cSaveOptions
.cClearCache
.cPrinterStop = False
.cDefaultPrinter = "PDFCreator"
.cPrintFile sDocument
End With
'
Set cConverterOptions = Nothing
Set cConverter = Nothing
'
End Sub
Figure my problem now is focus is bouncing between four applications
-
Feb 19th, 2008, 07:57 AM
#4
Re: PDFCreator
What is the exact problem? Are you getting errors?
-
Feb 19th, 2008, 06:08 PM
#5
Hyperactive Member
Re: PDFCreator
 Originally Posted by Hack
What is the exact problem? Are you getting errors?
If asking me, then I'm still working on it. The above works to convert a single word document to pdf, but doesn't work for multiple documents. At the moment working on moving the declarations around and seeing if I don't have to reset the word object after "printing" the first pdf document.
Never done this before so am having fun getting it to work
No doubt I'll get stuck somewhere though.
-
Feb 21st, 2008, 06:45 PM
#6
Hyperactive Member
Re: PDFCreator
Okay got this working for multiple documents. You need to do the merge first for all documents, then convert them to pdf. If anyone wants the code to do this can pop it over to you.
One problem left, how do you do the conversion without showing the word document each time? Have tried the normal things setting visible to false etc but still popping a word window for each document.
-
May 6th, 2010, 12:59 AM
#7
New Member
Re: PDFCreator
Hey KiwiDexter,
did you workout how to stop word openning? I am trying to get this working in Visual Studio 2008 with pdfcreator 0.9.9 and using their sample 1 code. it opens the word document at the . cPrintfile(fi.fullname) and then sits there until i exit out of the word doc. it does not create the pdf file. works fine for a txt file
Code:
With _PDFCreator
.cOptions = opt
.cClearCache()
DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
.cPrintFile(fi.FullName)
ReadyState = False
.cPrinterStop = False
End With
-
May 6th, 2010, 02:58 AM
#8
New Member
Re: PDFCreator
hi,
why dont u use cute PDF.......
advantage: it is hooked to ALL Programms as a printer and where u need it u can use it... and its FREE
kind regards
dieter
-
May 6th, 2010, 10:23 AM
#9
Addicted Member
Re: PDFCreator
... or ... use the Publish as PDF option of MS Word
-
May 6th, 2010, 08:27 PM
#10
New Member
Re: PDFCreator
 Originally Posted by HellsBells
hi,
why dont u use cute PDF.......
advantage: it is hooked to ALL Programms as a printer and where u need it u can use it... and its FREE
kind regards
dieter
Sorry but I am very new to vb programming. How do I reference Cutepdf so as to automate the save screen ( ie I dont want the save screen to show to the user, i want it to save to a predefined directory as a file name the same as the word doc)???? PDF Creator had sample vb code, does cutepdf????
-
May 6th, 2010, 08:49 PM
#11
Addicted Member
Re: PDFCreator
I believe most of the free PDF print drivers, whether it's CutePDF, PrimoPDF, DoIt PDF, (there are many) do not offer a silent option. If you upgrade to a paid version, that option is often available.
I'll ask again... why not use MS Office Automation to invoke Word's Publish as PDF option?
-
May 6th, 2010, 09:18 PM
#12
New Member
Re: PDFCreator
 Originally Posted by Tom Moran
I believe most of the free PDF print drivers, whether it's CutePDF, PrimoPDF, DoIt PDF, (there are many) do not offer a silent option. If you upgrade to a paid version, that option is often available.
I'll ask again... why not use MS Office Automation to invoke Word's Publish as PDF option?
unfortunately we are using 2003 and can not upgrade to 2007 in the near future
news flash
Found the issue, word macro security was set to high. set it to low and away it went.
Last edited by basbrian; May 7th, 2010 at 02:06 AM.
Reason: Found solution
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|