Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Create a macro to create excel line graph with coloured pointers anddata lables | Charts and Charting in Excel | |||
Create WB, create new Sht, paste data. (Macro not working) | Excel Programming | |||
create Macro €“ select data, sort by acc no., yr, part no, create P | Excel Programming | |||
how to create a macro that runs other macro in the same workbook | Excel Programming | |||
Use existing macro to create another macro | Excel Programming |