Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to create PDF

I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to create PDF

Hi gotahavit

The Ne number of a printer can be different for every user
You can try this to print to for example the Adobe PDF printer


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


"gotahavit" wrote in message ...
I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to create PDF

Thanks. It worked.

"Ron de Bruin" wrote:

Hi gotahavit

The Ne number of a printer can be different for every user
You can try this to print to for example the Adobe PDF printer


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


"gotahavit" wrote in message ...
I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to create PDF

You are welcome

Code is from Ole from this page
http://www.erlandsendata.no/english/...tchangeprinter



--

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


"gotahavit" wrote in message ...
Thanks. It worked.

"Ron de Bruin" wrote:

Hi gotahavit

The Ne number of a printer can be different for every user
You can try this to print to for example the Adobe PDF printer


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


"gotahavit" wrote in message ...
I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Macro to create PDF

Hi Ron.
I am succesfully using your RDB_Create_PDF function for creating PDF's
(thank you!)
Is there a way to make the PDFs password protected?
Thanks in advance,
Albert C.

"Ron de Bruin" wrote:

Hi gotahavit

The Ne number of a printer can be different for every user
You can try this to print to for example the Adobe PDF printer


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


"gotahavit" wrote in message ...
I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to create PDF

Hi Albert

I am no Adobe user so I can't help you
I am sure that Google will help you to find a example if it is possible with code

--

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




"Albert" wrote in message ...
Hi Ron.
I am succesfully using your RDB_Create_PDF function for creating PDF's
(thank you!)
Is there a way to make the PDFs password protected?
Thanks in advance,
Albert C.

"Ron de Bruin" wrote:

Hi gotahavit

The Ne number of a printer can be different for every user
You can try this to print to for example the Adobe PDF printer


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


"gotahavit" wrote in message ...
I have a macro that creates PDFs. Within the macro, I identify the active
printer: ActivePrinter:="Adobe PDF on Ne01:". I got this from recording a
macro. Well, when others try to use it, the Ne01 is different. For some it is
Ne03 and others Ne02. When those people run the macro it still creates a PDF,
but the font gets messed up.
Is there a way (within the macro) to identify a list of the available
printers, or the Ne# for the particular computer, or is there any other way
to go around the issue?

Thanks.


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
Create a macro to create excel line graph with coloured pointers anddata lables anuj datta Charts and Charting in Excel 1 September 30th 09 04:04 PM
Create WB, create new Sht, paste data. (Macro not working) Rick S. Excel Programming 6 October 31st 07 05:33 PM
create Macro €“ select data, sort by acc no., yr, part no, create P Johnny Excel Programming 0 November 22nd 06 03:18 PM
how to create a macro that runs other macro in the same workbook VB Script for Excel Excel Programming 4 March 23rd 06 03:53 AM
Use existing macro to create another macro fullers Excel Programming 1 February 16th 06 09:56 AM


All times are GMT +1. The time now is 08:40 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"