Solved

Create PDF from Word via VB

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe A recent question here at Experts Exchange piqued my interest, so I decided to provide a thorough solution and publ…
Have you ever come up with a need of emailing only few pages of PDF file to one of yourfriend or colleague, instead of whole Adobe file? If yes, then surely you have face problems in doing that! Read this section as I have suggested multiple solutio…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now