Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default What are the options in the print macro?

I'm trying to write VBA code to automatically print a page in an excel
worksheet in PDF format and control it's name as well.

I'm hoping the answer lies in the Excel Print macro -

ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""Adobe PDF on Ne09:"",,TRUE,,FALSE)"

I'm guessing that between one set of those commas is a place for a file name
etc.
Frankly I'd like to know what all the options are - what each space
designates.
Also, what would the syntax be for placing a string inside that?
Finally, I've notices that the "Ne09" designation for the printer changes
sometimes. How would I trap for that so that I could always be sure the
correct "Ne#" could be referenced. Thank you so much!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default What are the options in the print macro?

Excel 2007 record a ExecuteExcel4Macro, see the VBA help for Printout for the print options


You can use this function from Ole P Erlandsen

You use it in the macro like this

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"TKoel" wrote in message ...
I'm trying to write VBA code to automatically print a page in an excel
worksheet in PDF format and control it's name as well.

I'm hoping the answer lies in the Excel Print macro -

ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""Adobe PDF on Ne09:"",,TRUE,,FALSE)"

I'm guessing that between one set of those commas is a place for a file name
etc.
Frankly I'd like to know what all the options are - what each space
designates.
Also, what would the syntax be for placing a string inside that?
Finally, I've notices that the "Ne09" designation for the printer changes
sometimes. How would I trap for that so that I could always be sure the
correct "Ne#" could be referenced. Thank you so much!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print command options scarrigan Excel Discussion (Misc queries) 1 October 20th 08 08:42 PM
How can I copy print options from one tab to another tab? Sean Excel Discussion (Misc queries) 2 April 24th 08 02:06 AM
Copying Print Options IlliniEric Excel Discussion (Misc queries) 2 April 2nd 08 03:43 PM
How to set DEFAULT print options in Excel to print gridlines? LKR Excel Discussion (Misc queries) 1 September 23rd 05 06:16 PM
print options andrew a Excel Discussion (Misc queries) 1 August 29th 05 09:52 PM


All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"