Solved

convert word to pdf(urgent)

Posted on 2002-06-27
9
487 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
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
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

 

Accepted Solution

by:
masterofhisdomain earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Hi wilsontang, if you fixed the problem then please post the solution here

:O)Bruintje
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

6 Experts available now in Live!

Get 1:1 Help Now