Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default selecting a printer within a macro

I wish to select a printer from within a macro. I have the printer name but
since it is a network printer the channel changes from machine to machine.
Can you index through all available printer and select the one you want.

All help is greatly appreciated.
OlieH
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default selecting a printer within a macro

One approach:
strActiveprinter = ActivePrinter 'Capture current printer
Application.Dialogs(xlDialogPrinterSetup).Show
.....
....
activeprinter = stractiveprinter 'Reset the printer


If you want to try to set the printer programmatically, you'll likely need
an API function to return an array of the printers installed on the machine,
then loop through those to find the one you want.

Tom Ogilvy posted some info on this:

http://www.microsoft.com/office/comm...xp=&sloc=en-us




"OlieH" wrote:

I wish to select a printer from within a macro. I have the printer name but
since it is a network printer the channel changes from machine to machine.
Can you index through all available printer and select the one you want.

All help is greatly appreciated.
OlieH

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default selecting a printer within a macro

JMB; does such a function exists? I think this is what I am needing. I am
currently using the .show command and make the operator select the correct
one and then recheck to make sure they do so.

"JMB" wrote:

One approach:
strActiveprinter = ActivePrinter 'Capture current printer
Application.Dialogs(xlDialogPrinterSetup).Show
....
...
activeprinter = stractiveprinter 'Reset the printer


If you want to try to set the printer programmatically, you'll likely need
an API function to return an array of the printers installed on the machine,
then loop through those to find the one you want.

Tom Ogilvy posted some info on this:

http://www.microsoft.com/office/comm...xp=&sloc=en-us




"OlieH" wrote:

I wish to select a printer from within a macro. I have the printer name but
since it is a network printer the channel changes from machine to machine.
Can you index through all available printer and select the one you want.

All help is greatly appreciated.
OlieH

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default selecting a printer within a macro

Hmm.. that link I posted did not work. Actually, I misspoke, although you
can use API to return an array of printers, you can also use WScript (which
is what the link to Tom's post was supposed to show you). Here is code
previously posted by Norman Jones that uses the same method:

Sub ListPrinters()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print oPrinters.Item(iCount + 1)
Next
End Sub


"OlieH" wrote:

JMB; does such a function exists? I think this is what I am needing. I am
currently using the .show command and make the operator select the correct
one and then recheck to make sure they do so.

"JMB" wrote:

One approach:
strActiveprinter = ActivePrinter 'Capture current printer
Application.Dialogs(xlDialogPrinterSetup).Show
....
...
activeprinter = stractiveprinter 'Reset the printer


If you want to try to set the printer programmatically, you'll likely need
an API function to return an array of the printers installed on the machine,
then loop through those to find the one you want.

Tom Ogilvy posted some info on this:

http://www.microsoft.com/office/comm...xp=&sloc=en-us




"OlieH" wrote:

I wish to select a printer from within a macro. I have the printer name but
since it is a network printer the channel changes from machine to machine.
Can you index through all available printer and select the one you want.

All help is greatly appreciated.
OlieH

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default selecting a printer within a macro

JMB wrote:
Hmm.. that link I posted did not work. Actually, I misspoke, although you
can use API to return an array of printers, you can also use WScript (which
is what the link to Tom's post was supposed to show you). Here is code
previously posted by Norman Jones that uses the same method:

Sub ListPrinters()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")



Depending how many network computors you have, something like this might help.
..


If computername = "UKWD3577" Then Application.ActivePrinter = "HP Officejet
Pro K550 Series on Ne00:"
If computername = "UKWD3636" Then Application.ActivePrinter = "\\
UKWD3577\HP Officejet Pro K550 Series on Ne01:"
If computername = "UKWD3567" Then Application.ActivePrinter = "\\
UKWD3577\HP Officejet Pro K550 Series on Ne02:"
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print oPrinters.Item(iCount + 1)
Next
End Sub

JMB; does such a function exists? I think this is what I am needing. I am
currently using the .show command and make the operator select the correct

[quoted text clipped - 21 lines]
All help is greatly appreciated.
OlieH


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1



  #6   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default selecting a printer within a macro

One downside could be if the computer names change (the office gets new
machines) and the code needs to be changed to reflect the new machine names.


"Francois via OfficeKB.com" wrote:

JMB wrote:
Hmm.. that link I posted did not work. Actually, I misspoke, although you
can use API to return an array of printers, you can also use WScript (which
is what the link to Tom's post was supposed to show you). Here is code
previously posted by Norman Jones that uses the same method:

Sub ListPrinters()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")



Depending how many network computors you have, something like this might help.
..


If computername = "UKWD3577" Then Application.ActivePrinter = "HP Officejet
Pro K550 Series on Ne00:"
If computername = "UKWD3636" Then Application.ActivePrinter = "\\
UKWD3577\HP Officejet Pro K550 Series on Ne01:"
If computername = "UKWD3567" Then Application.ActivePrinter = "\\
UKWD3577\HP Officejet Pro K550 Series on Ne02:"
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print oPrinters.Item(iCount + 1)
Next
End Sub

JMB; does such a function exists? I think this is what I am needing. I am
currently using the .show command and make the operator select the correct

[quoted text clipped - 21 lines]
All help is greatly appreciated.
OlieH


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1


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
Selecting printer in a macro lohme Excel Discussion (Misc queries) 4 January 2nd 07 06:36 PM
selecting printer Aaron Excel Programming 1 March 22nd 06 10:28 PM
Selecting A Printer With VBA Minitman[_4_] Excel Programming 4 October 21st 04 05:51 PM
Selecting printer from macro BrianG[_4_] Excel Programming 5 June 9th 04 10:43 PM
Selecting a printer Robin Clay[_3_] Excel Programming 0 February 2nd 04 06:25 PM


All times are GMT +1. The time now is 02:25 AM.

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

About Us

"It's about Microsoft Excel"