Solved

Create PDF from Word via VB

Posted on 2003-10-24
7
3,645 Views
Last Modified: 2008-03-17
I need to create a PDF file of a Word document using VB.
The existing links in the word document MUST be kept in the new PDF document.
If the macro "ConvertToPDF" is included in the answer I need to know how to overcome the problem with answering yes or no while saving or overwriting files.
Actually, I would be happy if I know what was hided behind the "ConvertToPDF" macro!

Thanks a lot
Vestigo
0
Comment
Question by:vestigo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:antonieraj
ID: 9619134
Hi
creating a PDF file of a Word document using VB

Private Sub Command1_Click()
Dim wrd As New Word.Application
Dim doc As Word.Document
wrd.Visible = False
wrd.ScreenUpdating = False
wrd.ActivePrinter = "Acrobat Distiller"
'Open the document
Set doc = wrd.Documents.Open("c:\worddoc.doc")
'Print it to a PostScript file using Distiller
doc.PrintOut False, False, , "c:\test.ps", , , , , , , True
doc.Close False
wrd.Quit False
Set doc = Nothing
Set wrd = Nothing
'Now call distiller to convert the postscript file to PDF
Dim acr As New ACRODISTXLib.PdfDistiller
acr.bShowWindow = False
acr.FileToPDF "c:\test.ps", "pdfdoc.pdf", ""
Set acr = Nothing
'Delete the old PS file
Kill "c:\test.ps"
'Done

End Sub

0
 

Author Comment

by:vestigo
ID: 9620017
Thanks for your proposal.
I already tried this. (example found another place in this forum)
The problem with this routine is, as pinpointed, that the links does not retain in the PDF document.
It may happen there is an easy solution to this, but unfortunately I'm not able to see it. :-/
The same happens when I tried to use Destiller to print to PDF via Word using VB.
("appWord.ActiveDocument.PrintOut…."  …so, why bother go via a postscript file?)

By the way, as this was my first question in Experts-Exchange I'm not familiar with this point system. Yes, you may say that I need to read the rules etc. When I asked my question I was request not to be a skinflint. So I gave it 250 points. (as I think it's worth compared with points given to other answers in this forum)  From where I get these magic points I do not know, please guide me!

yours sincerely
Vestigo, Norway (the land of polar bear)
0
 
LVL 4

Accepted Solution

by:
antonieraj earned 250 total points
ID: 9656937
Hi

If u have Acrobat PDFMaker u can easily convert directly from word to PDF
U can use them in VBA and VB

If u are need of settings and documentation check this site for conversion

http://www.performancegraphics.com/PCC/PDFclass/Word2PDF.htm.


Regarding Using of ("appWord.ActiveDocument.PrintOut…."  …so, why bother go via a postscript file?) and Distriller it - Is the font embeddeding and resolution of images can be kept or increased with Distriller job option settings and with  pdfmark command we can add information to pdf.  Neither directly printing with 'PDF writer'.

With Distriller and PDF writer converting from word to PDF. Preservation of Bookmark is not possible.

with PDFMarker preservation of bookmark can be done.
There are more share tools available in net which preserve bookmarks and link for conversion from word to pdf.

pdf factory fineprint
pdf995






 


0
 
LVL 1

Expert Comment

by:mal4mac
ID: 9990742
Upgrade to Acrobat 6, a button is inserted into word. Click the button, PDF is created with links retained. More details:

www.321books.co.uk
0
 
LVL 9

Expert Comment

by:p_sie
ID: 10441535
I need to know how to overcome the problem with answering yes or no while saving or overwriting files.

Use

Dim wrd As New Word.Application

wrd.Displayalerts = False

after save

wrd.Displayalerts = True

will not show an overwrite question.
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
Power PDF (http://www.nuance.com/for-business/document-imaging-and-scanning/power-pdf-converter/index.htm) is the newest product from the Document Imaging division of Nuance Communications (http://www.nuance.com/). It is available in two editions — …
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question