Solved

Disable dialogue box

Posted on 2002-07-02
5
230 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 49

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

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

705 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

16 Experts available now in Live!

Get 1:1 Help Now