Solved

convert word to pdf(urgent)

Posted on 2002-06-27
9
523 Views
Last Modified: 2007-12-19
hi experts,

Can anybody help me? It is urgent!! I'm using PDFWriter to convert my Word doc to pdf. My problem is it keeps on asking me for a filename. My program is a batch process that needs to create individual pdf file for each record.

   Dim msWord As Word.Application
   Set msWord = GetObject(Class:="Word.Application.8")

   msWord.Visible = False
   msWord.ActivePrinter = "Acrobat PDFWriter"
   msWord.Documents.Open "c:\temp\spec.doc"
   msWord.ActiveDocument.PrintOut    

How to convert a file in other language such as chinese? Convertion in english version is correct.
Thanks!!

0
Comment
Question by:wilsontang
[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
9 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7115605
Hi wilsontang,

have you tried something similar as this?
http://www.codecuts.com/mainpage.asp?webpageid=350

they do something like

Function ConvertFile(strSourceFileName As String) As String
On Error GoTo ErrorHandler

Dim msWord As Word.Application
Set msWord = GetObject(Class:="Word.Application.8")

msWord.Visible = True
msWord.ActivePrinter = "Acrobat Distiller"
msWord.Documents.Open strSourceFileName
msWord.ActiveDocument.PrintOut
msWord.ActiveDocument.Close False

' Should check and quit word when done
Set msWord = Nothing
ConvertFile = True
Exit Function

instead of distiller they use pdfwriter but it is more the way they handle the silent printing

HAGD:O)Bruintje
0
 

Author Comment

by:wilsontang
ID: 7115663
hi bruintje,
        Thanks for your help first.
My program is copied from the site you post. I just have pdf writer driver installed on my computer, no acrobat distiller. So i must set the Active Printer to "Acrobat PDFWriter" as the pdf printer driver name. I want to know which attribute or function of the API "Word.Application.8" can set it to silent printing(no any dialog box pop up)

my program is as follows:

Function ConvertFile(strSourceFileName As String, strDestinationFileName As String) As String

   Dim msWord As Word.Application
   Set msWord = GetObject(Class:="Word.Application.8")

   msWord.Visible = False
   msWord.ActivePrinter = "Acrobat PDFWriter"
   msWord.Documents.Open strSourceFileName
   msWord.ActiveDocument.Save
   msWord.ActiveDocument.PrintOut

   msWord.ActiveDocument.Close False

   Set msWord = Nothing
   ConvertFile = True
Exit Function

wilson
0
 

Author Comment

by:wilsontang
ID: 7115692
hi bruintje,
        Thanks for your help first.
My program is copied from the site you post. I just have pdf writer driver installed on my computer, no acrobat distiller. So i must set the Active Printer to "Acrobat PDFWriter" as the pdf printer driver name. I want to know which attribute or function of the API "Word.Application.8" can set it to silent printing(no any dialog box pop up)

my program is as follows:

Function ConvertFile(strSourceFileName As String, strDestinationFileName As String) As String

   Dim msWord As Word.Application
   Set msWord = GetObject(Class:="Word.Application.8")

   msWord.Visible = False
   msWord.ActivePrinter = "Acrobat PDFWriter"
   msWord.Documents.Open strSourceFileName
   msWord.ActiveDocument.Save
   msWord.ActiveDocument.PrintOut

   msWord.ActiveDocument.Close False

   Set msWord = Nothing
   ConvertFile = True
Exit Function

wilson
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Expert Comment

by:bruintje
ID: 7115728
seem to get no notifs and i got no way to test here but here's another snippet printing excel sheets to pdf

http://www.codecuts.com/mainpage.asp?WebPageID=293

it seems not to use distiller or pdfwriter maybe worth a try anyway
0
 

Accepted Solution

by:
masterofhisdomain earned 150 total points
ID: 7207611
I found you can do this with your code to have it not prompt you for a file name. (PDF Writer seems to add the pdf extension automatically)

  Dim msWord As Word.Application
  Set msWord = GetObject(Class:="Word.Application.8")

  msWord.Visible = False
  msWord.ActivePrinter = "Acrobat PDFWriter"
  msWord.Documents.Open "c:\temp\spec.doc"
  msWord.ActiveDocument.PrintOut OutputFileName:="C:\temp\spec"  

The problem i have is i get a second empty file when i do this, but i do not get a prompt.

Masterofhisdomain
0
 

Author Comment

by:wilsontang
ID: 7208937
hi Masterofhisdomain,
           Thanks for your replied message!!
I've already fixed my problem. For your problem, I think you can ommit the attribute of OutputFileName. PDFWriter will output the file to the port you select. Go to your PDF distiller's setting, you can add a new PDF port for your output folder.

wilson
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7210300
Hi wilsontang, if you fixed the problem then please post the solution here

:O)Bruintje
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7964630
Hi wilsontang,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept masterofhisdomain's comment(s) as an answer.

wilsontang, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8014881
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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