PDA

View Full Version : Changing Word Documents to PDF using VB 6


RARTIGAS
10-19-2004, 09:59 AM
:confused:

****o I am currently trying to convert Word Documents to PDF using Visual Basic 6.0 and the code Im using seems to be converting the document, but when I try to open the pdf I get this message:

Adobe Reader could not open 'BSXC70.pdf' because it is either not a supported file type or because the file has been corrupted.

BSX70 is the name of the pdf. However, if I do it manually from Word, it works fine. The code Im using is as follows:

objWordDoc.PrintOut Background:=0, Range:=wdPrintAllDocument, outputFilename:="C:\My Documents\PDF Files Test\BSX70.pdf",
Item:=wdPrintDocumentContent, Copies:=1, pagetype:=wdPrintAllPages, PrintToFile:=True, collate:=False

objWordDoc is the word document to change to pdf.
I tried it with just the Background and Range, eliminating the Output File Name and when I ran the program I got the Primo PDF screen that asks for a "save as" destination. I entered the folder path and it worked fine using the vb script. But the idea is to have the program select the destination path in code.
I dont know if this is too technical, but any help would be apreciated.
Thanx.

Douglas Saltsman
10-20-2004, 03:26 PM
:confused:

****o I am currently trying to convert Word Documents to PDF using Visual Basic 6.0 and the code Im using seems to be converting the document, but when I try to open the pdf I get this message:

Adobe Reader could not open 'BSXC70.pdf' because it is either not a supported file type or because the file has been corrupted.

BSX70 is the name of the pdf. However, if I do it manually from Word, it works fine. The code Im using is as follows:

objWordDoc.PrintOut Background:=0, Range:=wdPrintAllDocument, outputFilename:="C:\My Documents\PDF Files Test\BSX70.pdf",
Item:=wdPrintDocumentContent, Copies:=1, pagetype:=wdPrintAllPages, PrintToFile:=True, collate:=False

objWordDoc is the word document to change to pdf.
I tried it with just the Background and Range, eliminating the Output File Name and when I ran the program I got the Primo PDF screen that asks for a "save as" destination. I entered the folder path and it worked fine using the vb script. But the idea is to have the program select the destination path in code.
I dont know if this is too technical, but any help would be apreciated.
Thanx.


What you are doing is creating a postscript file from the word doc object. There is no conversion to PDF taking place in your code. There is also no API to Primo so you will not be able to do this programmatically.

There is an application called "Server" available at www.activepdf.com that will do exactly what you're looking for and provides an example of this exact scenario in the documentation.

RARTIGAS
10-25-2004, 05:04 AM
****o Douglas

Thank's for the info and the quick reply.

RARTIGAS

shijobaby
02-14-2010, 08:40 PM
http://vbprogrammingerrors.blogspot.com/2010/02/cannot-open-or-find-file-when.html