Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default 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
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
Double-sided printing and printing entire workbook in one go. Macro to help ... ?? StargateFan Excel Programming 7 March 31st 11 01:57 AM
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
Excel Printing --Borders are not printing on the same page as data Stup88 Excel Discussion (Misc queries) 1 August 7th 07 09:34 AM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM
Printing? Worksheets not printing the same on multiple pc's! 43fan Excel Programming 2 April 29th 04 02:34 PM


All times are GMT +1. The time now is 01:51 PM.

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

About Us

"It's about Microsoft Excel"