Printing to pdf


B

Brian

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?
 
Ad

Advertisements

I

isabelle

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?
 
B

Brian

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 :

and then reseting the workbook to the default printer

On checking it i found that the pdf printer had changed to

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 numberersin 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 gointo 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 pdfprinter 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.
 
Ad

Advertisements

I

isabelle

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top