Solved

convert word to pdf(urgent)

Posted on 2002-06-27
9
514 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
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
Industry Leaders: 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

733 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