[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 564
  • Last Modified:

convert word to pdf(urgent)

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
wilsontang
Asked:
wilsontang
1 Solution
 
bruintjeCommented:
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
 
wilsontangAuthor Commented:
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
 
wilsontangAuthor Commented:
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!

 
bruintjeCommented:
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
 
masterofhisdomainCommented:
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
 
wilsontangAuthor Commented:
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
 
bruintjeCommented:
Hi wilsontang, if you fixed the problem then please post the solution here

:O)Bruintje
0
 
DanRollinsCommented:
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
 
NetminderCommented:
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now