Solved

Create PDF from Word via VB

Posted on 2003-10-24
7
3,638 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

740 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