Solved

Disable dialogue box

Posted on 2002-07-02
5
233 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
5 Comments
 
LVL 16

Expert Comment

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
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…

828 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