Solved

Disable dialogue box

Posted on 2002-07-02
5
235 Views
Last Modified: 2010-05-02
hi experts,

Can anybody help me? It is urgent!! I'm writing a VB program using PDFWriter driver 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
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7125821
hearing...
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 7126251
0
 
LVL 1

Accepted Solution

by:
sclaverie earned 300 total points
ID: 7335314
Hey,

Using PDFWriter, you can "print" the Word document to a specific pdf file, without the dialog.  You will have to set a few Abode registry settings, but one of them will be to turn the dialog off as well as to specify the name of the file.  
All the registry settings are defined in the Acrobat PDFWriter API Reference pdf file shipped with the full version of Acrobat (Program Files\Adobe\Acrobat SDK\Documentation\PDF_Creation_APIs). All registry keys related to saving/previewing the pdf file using the PDFWriter can be found under HKCU/Software/Adobe/Adobe PDFWriter.

Here's some code using Word automation and PDFWriter.

'********************************
Public Const AdobeKey = "SOFTWARE\Adobe\Acrobat PDFWriter\"


Public Sub WordToPDF()

Dim oleWord As Word.Application
Dim WordDoc As Word.Document
Dim oldPrinter As String

'We are changing the Printer in Word to PDFWriter, so save the old printer here
oldPrinter = cSetPrinter.m_sPrevPrinterDevName
Set oleWord = New Word.Application

'get word doc
Set WordDoc = oleWord.Documents.Open("c:\somedoc.doc")

'Do whatever you may need to do to the word doc here

SetPDFParams "c:\somedoc.pdf", False, False
oleWord.ActivePrinter = "Acrobat PDFWriter"
WordDoc.PrintOut True
                     
WordDoc.Close False
Set WordDoc = Nothing
Set oleWord = Nothing
cSetPrinter.SetPrinterAsDefault oldPrinter
end sub


Public Sub SetPDFParams(Filename As String, Landscape As Boolean, ShowViewer As Boolean)
'This sets the registry settings for Adobe
Dim regsuccess As Long

On Error Resume Next
'regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "bDocInfo", "1")
regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "PDFFileName", Filename)

If ShowViewer Then
   regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "bExecViewer", "1")
Else
   regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "bExecViewer", "0")
End If

If Landscape Then
   regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "orient", "2") 'Portrait = 1, Landscape = 2
Else
   regsuccess = RegWriteString(HKEY_CURRENT_USER, AdobeKey, "orient", "1")
End If

End Sub
'********************************

Hope that helps.

Later...
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7971229
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 sclaverie'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
 

Expert Comment

by:SpideyMod
ID: 8018771
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

738 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