pdf converter within Word VBA

G

Gerie Alards

Hello,

does somebody know whether or not the existence of a pdf converter like
the following example from msdn of a Wordperfect converter describes.

Sub OpenDoc2()
Dim fmt As Variant
fmt = Application.FileConverters("WordPerfect6x").OpenFormat
Documents.Open FileName:="C:\MyFiles\Test.wp", Format:=fmt
End Sub

PDF files directly downloaded from Internet e.g.:
Documents.Open "http://www.amnesty.nl/young-amnesty/downloads/rusland.pdf"
Documents(1).SaveAs "D:\t.pdf"

Are not valid PDF files.

Thanks in advance for your input,

gerie alards
 
P

Perry

No PDF file converters available in pre Office12 versions.
There's is however a way to produce PDF files, using the Acrobat Distiller
interface in Office 11, 10 or 2K (97?)
Requirements:
- Acrobat Distiller installed on client.
- In yr template project: references needed pointing to Acrobat Distiller
library and Scripting Runtime.

Below snip creates a PDF file from the ActiveDocument.

Dim oDist As New PdfDistiller
Dim sFolder As String
Dim fso As New FileSystemObject
Dim sPDFFile As String

'Name target PDF file
sPDFFile = "c:\temp\MyPDFFile.pdf"

'set name of tempfile
sTempFile = "c:\temp\" + fso.GetTempName()
'Print output to PS tempfile
ActiveDocument.PrintOut False, , , sTempFile
'create PDF
oDist.FileToPDF sTempFile, sPDFFile, "Print"

Krgrds,
Perry
 
G

Gerie Alards

Hi Perry,

Thanks for your input.
I forgot to mention that I work with Office 2003 VBA 6.3

(There are 26 converters availble see list below)

I generated all possible 26 pdf files from each converter as follow:

Dim fc as FileConverter
Dim PadFile As String

PadFile = "http://www.amnesty.nl/young-amnesty/downloads/rusland.pdf"
For Each fc In Application.FileConverters
Documents.Open PadFile, Format:=fc.ClassName
Documents(1).SaveAs "D:\" & fc.ClassName & ".pdf"
Documents(1).Close
Next fc
At the end none them results in a readable Pdf file.

The PdfDistiller you mentioned is not installed on my client.

regards,
gerie alards

available converters:
MSWorksWin4, MSWord6RTFExp, wks632, MSWordWin2, MSWorksWin5, MSWordMac4,
MSWordMac51, MSWordMac5,
WrdPrfctDOS50, WrdPrfctDOS51, WrdPrfctDat50, WrdPrfctDat, WrdPrfctWin,
WordPerfect6x, Recover, WrdPrfctDos, MSBiff,
MSWordMac, MSPAB, OUTLOOK, SPLUS, Works2000, Works2001, MSWinWrite.wpc,
MSWord6.wpc, MSWorksWin6

-o-o-o-o-o-o-o-o
 
J

Jonathan West

Hi Gerie,

There is no PDF converter available within Office 2003 (it will be available
in Office 12 which will probably be released in the second half of this
year)

This means you need to use an external add-in for creating PDFs. Acrobat
Distiller (available as part of Acrobat from Adobe) is the authoritative
version - as the PDF file format was invented by Adobe, but there are
others. Generally converting to PDF involves a "printing" to the file rather
than having a Save As process, as PDF is a form of compressed Postscript.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
G

Gerie Alards

Jonathan,

Thanks. At least the good news is that I can stop looking in the direction I
used so far and go further in the direction Perry also mentioned or rest in
peace
till the new release arrives.

regards,
gerie alards
 
Top