Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Macro in Word  (Read 2039 times)

0 Members and 1 Guest are viewing this topic.

Striver

  • Guest
Macro in Word
« on: July 06, 2006, 07:20:09 AM »
Hi,

I'm trying to write a macro in a Word document (Testdoc.doc) that will print the file Testdoc.doc to a pdf file. This is the function (in Visual Basic) in the macro that does that:

Public Sub bd2pdf_print(Printer As String, FilePath As String, OutputFile As String)
  
  ActivePrinter = Printer

  Application.PrintOut FileName:=FilePath, Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="1", PageType:=wdPrintAllPages, _
        Collate:=True, Background:=False, PrintToFile:=True, OutputFileName:=OutputFile, _
        Append:=False

End Sub

Public Sub bd2pdf_close()
 ActiveDocument.Close wdDoNotSaveChanges
End Sub

The parameters "Printer, FilePath, OutputFile" are submitted by a Visual Basic program that I have.
So in that program, I open the word document and then use the command: docapp.Run "bd2pdf_close" (where docapp is Word application) to run the macro. I actually manage to generate a pdf file, but there is something wrong with it. So I wonder if maybe this is correct what I do?
Grateful for help!

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Macro in Word
« Reply #1 on: July 07, 2006, 03:41:57 AM »
Quote
I actually manage to generate a pdf file, but there is something wrong with it.
What exactly is wrong with it?

Is there a particular reason why you need to do this programatically?  You could install PrimoPDF and use that to generate the PDF...?
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos