Create PDF from Word via VB

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
vestigoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
antonierajCommented:
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
 
vestigoAuthor Commented:
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
 
antonierajCommented:
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
mal4macCommented:
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
 
p_sieCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.