G
Gilley
I have searched and searched for a solution to my problem. I have found bits
and pieces but nothing to tie it all together.
I have a macro which basically does the following:
Saves a merge document to an RTF file.
Prints the saved RTF file to a PDF file.
Prints the saved RTF file to the printer on LPT1.
Closes the active window.
Deletes the RTF file.
Closes remaining open windows.
The problem lies in switching between the Adobe printer and the printer on
LPT1. This template, which contains the macro, will be distributed on
several different computers. Each computer has its own printer with its own
name.
I am saving to the RTF file so that the PDF file is forced to have the same
name in a specific directory.
Below is my macro (such as it is right now)!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub OSDFileSaveAsRTF()
'
' OSDFileSaveAsRTF Macro
' Save merged file as an RTF file
'
With ActiveDocument.Bookmarks
strFileName = .Item("OSDNumber").Range.Text
strFileName = strFileName & .Item("BasicForm").Range.Text
End With
ActiveDocument.SaveAs FileName:="c:\osd\" & strFileName & ".rtf", _
fileformat:=wdFormatRTF
'Print saved RTF File to PDF File
With Dialogs(wdDialogFilePrintSetup)
.Printer = "Adobe PDF"
.DoNotSetAsSysDefault = True
.Execute
End With
'ActivePrinter = "Adobe PDF"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'Delete RTF File
ActiveDocument.Close
Kill "c:\osd\" & strFileName & ".rtf"
'Close remaining active documents
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I hope you can make heads or tails from the above since the line breaks are
messed up.
I basically want to make sure at the end of the process that the default
printer is the printer on LPT1 not Adobe PDF. No matter what I do, the
default printer keeps getting switched over.
Any help would be appreciated. And thanks in advance.
Regards,
Gilley
aka DilbertIsMyHero
and pieces but nothing to tie it all together.
I have a macro which basically does the following:
Saves a merge document to an RTF file.
Prints the saved RTF file to a PDF file.
Prints the saved RTF file to the printer on LPT1.
Closes the active window.
Deletes the RTF file.
Closes remaining open windows.
The problem lies in switching between the Adobe printer and the printer on
LPT1. This template, which contains the macro, will be distributed on
several different computers. Each computer has its own printer with its own
name.
I am saving to the RTF file so that the PDF file is forced to have the same
name in a specific directory.
Below is my macro (such as it is right now)!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub OSDFileSaveAsRTF()
'
' OSDFileSaveAsRTF Macro
' Save merged file as an RTF file
'
With ActiveDocument.Bookmarks
strFileName = .Item("OSDNumber").Range.Text
strFileName = strFileName & .Item("BasicForm").Range.Text
End With
ActiveDocument.SaveAs FileName:="c:\osd\" & strFileName & ".rtf", _
fileformat:=wdFormatRTF
'Print saved RTF File to PDF File
With Dialogs(wdDialogFilePrintSetup)
.Printer = "Adobe PDF"
.DoNotSetAsSysDefault = True
.Execute
End With
'ActivePrinter = "Adobe PDF"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'Delete RTF File
ActiveDocument.Close
Kill "c:\osd\" & strFileName & ".rtf"
'Close remaining active documents
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I hope you can make heads or tails from the above since the line breaks are
messed up.
I basically want to make sure at the end of the process that the default
printer is the printer on LPT1 not Adobe PDF. No matter what I do, the
default printer keeps getting switched over.
Any help would be appreciated. And thanks in advance.
Regards,
Gilley
aka DilbertIsMyHero