Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to pdf
I am using Excel 2007 and have this code to print a document to pdf using Nitro Professional 7 and then reseting the workbook to the default printer Sub PrintPersonalPdf() Dim strPName As String strPName = Application.ActivePrinter Application.ActivePrinter = "Nitro PDF Creator 2 on Ne08:" Application.Run "PrintPersonalFax" Application.ActivePrinter = strPName End Sub The problem I have is that as soon as I removed my laptop from my network the code did not work. On checking it i found that the pdf printer had changed to "Nitro PDF Creator 2 on Ne04:" . Does the Ne04 refer to the port being used? This workbook is used on a number of different computers where I do not know the default printer or even if they have Nitro Professional installed. Is there some way to check if Nitro is installed and then set my code to the correct setting for the pdf printer as set on that computer? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to pdf
hi Brian,
Sub PrintPersonalPdf() Dim strPName As String, port As String strPName = Application.ActivePrinter port = Right(Split(strPName, ":")(0), 4) Application.ActivePrinter = "Nitro PDF Creator 2 on " & port & ":" Application.Run "PrintPersonalFax" Application.ActivePrinter = strPName End Sub -- isabelle Le 2012-05-03 08:17, Brian a écrit : I am using Excel 2007 and have this code to print a document to pdf using Nitro Professional 7 and then reseting the workbook to the default printer Sub PrintPersonalPdf() Dim strPName As String strPName = Application.ActivePrinter Application.ActivePrinter = "Nitro PDF Creator 2 on Ne08:" Application.Run "PrintPersonalFax" Application.ActivePrinter = strPName End Sub The problem I have is that as soon as I removed my laptop from my network the code did not work. On checking it i found that the pdf printer had changed to "Nitro PDF Creator 2 on Ne04:" . Does the Ne04 refer to the port being used? This workbook is used on a number of different computers where I do not know the default printer or even if they have Nitro Professional installed. Is there some way to check if Nitro is installed and then set my code to the correct setting for the pdf printer as set on that computer? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to pdf
On Thursday, May 3, 2012 3:52:40 PM UTC+2, isabelle wrote:
hi Brian, Sub PrintPersonalPdf() Dim strPName As String, port As String strPName = Application.ActivePrinter port = Right(Split(strPName, ":")(0), 4) Application.ActivePrinter = "Nitro PDF Creator 2 on " & port & ":" Application.Run "PrintPersonalFax" Application.ActivePrinter = strPName End Sub -- isabelle Le 2012-05-03 08:17, Brian a écrit : I am using Excel 2007 and have this code to print a document to pdf using Nitro Professional 7 and then reseting the workbook to the default printer Sub PrintPersonalPdf() Dim strPName As String strPName = Application.ActivePrinter Application.ActivePrinter = "Nitro PDF Creator 2 on Ne08:" Application.Run "PrintPersonalFax" Application.ActivePrinter = strPName End Sub The problem I have is that as soon as I removed my laptop from my network the code did not work. On checking it i found that the pdf printer had changed to "Nitro PDF Creator 2 on Ne04:" . Does the Ne04 refer to the port being used? This workbook is used on a number of different computers where I do not know the default printer or even if they have Nitro Professional installed. Is there some way to check if Nitro is installed and then set my code to the correct setting for the pdf printer as set on that computer? isabelle, Thank you for this reply but as soon as I get to "Applicaation Activeprinter = Nitro ... " I get an error. I can see this is happening because my computer is set to my default printer which when I use it the last numberers in the Macro appear as "on Ne03" but when I use the Pdf printer it appears as "on Ne04". As this will be different for each computer I need to establish if the pdf printer is one of the printers available on that computer and if I use that prinerter what pert is it connected to and that has to go into my macro and when the macro has run it then needs to reset that computer to the default printer. In your example you seem to be setting the pdf printer to the same port as the default printer. Also from your code you seem to end on ":" which means the colon is last. should there not still be a quaotation mark after that? Sorry, you obviously know a lot more about this than me so maybe I am talking nonsense. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to pdf
hi Brian,
if i understand well you need to check first the printers connected the post Sub ListsPrinters() Dim oFSO As Object Dim WshNetwork As Object Dim oPrinters As Object Dim sChaine As String, i As Integer, x As Integer, pt As String sChaine = "Printers connected to the post :" Set oFSO = CreateObject("Scripting.FileSystemObject") Set WshNetwork = CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 To oPrinters.Count - 1 Step 2 If oPrinters.Item(i) = "LPT1:" Then pt = oPrinters.Item(i): x = -1 Else pt = "NE0" & x sChaine = sChaine & vbCrLf & vbCrLf & "Port " & pt & " = " & oPrinters.Item(i + 1) x = x + 1 Next MsgBox sChaine End Sub -- isabelle Le 2012-05-03 11:52, Brian a écrit : Thank you for this reply but as soon as I get to "Applicaation Activeprinter = Nitro ... " I get an error. I can see this is happening because my computer is set to my default printer which when I use it the last numberers in the Macro appear as "on Ne03" but when I use the Pdf printer it appears as "on Ne04". As this will be different for each computer I need to establish if the pdf printer is one of the printers available on that computer and if I use that prinerter what pert is it connected to and that has to go into my macro and when the macro has run it then needs to reset that computer to the default printer. In your example you seem to be setting the pdf printer to the same port as the default printer. Also from your code you seem to end on ":" which means the colon is last. should there not still be a quaotation mark after that? Sorry, you obviously know a lot more about this than me so maybe I am talking nonsense. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Double-sided printing and printing entire workbook in one go. Macro to help ... ?? | Excel Programming | |||
Excel 2003 printing problem--printing 1 document on 2 pages | Excel Discussion (Misc queries) | |||
Excel Printing --Borders are not printing on the same page as data | Excel Discussion (Misc queries) | |||
Enable Double sided printing contiuously when printing multiple s. | Excel Discussion (Misc queries) | |||
Printing? Worksheets not printing the same on multiple pc's! | Excel Programming |