Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing Problem
I have two shared printers on two seperate hard wired networked, desktop
computers. One prints tractor fed labels for Serums, and one prints instructions on regular letter paper. The patient information is entered on a laptop which connects wirelessly to the newtork. I use an Excel Macro assigned to two different buttons to select the proper printer and the range to print. This setup works great....Until I introduce a second laptop, using the same Excel version (2007) and same code. Both laptops access each printer perfectly for printing the "Test Page". However the Printer Macros on one or the other laptops fails to work. If I re-record the marcos they work again. (Manual Printing works fine always) On careful examination of the macro code, I find that the "ne03", for example, has changed to "ne05" in the new code on the printer line. What would be a strategy to avoid having to re-record the macros? Thanks-a very puzzled RMS |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing Problem
Well I could find several solutions to your problem. For example this is a
part of code that by "brute force" selects the propper printer: (from: http://www.tek-tips.com/viewthread.cfm?qid=879030) --- Function NetworkPrinter(ByVal myprinter As String) On Error Resume Next Dim NetWork As Variant Dim X As Integer '/// Define NetWork Array \\\ NetWork = Array("Ne00:", "Ne01:", "Ne02:", "Ne03:", "Ne04:", _ "Ne05:", "Ne06:", "Ne07:", "Ne08:", _ "Ne09:", "Ne10:", "Ne11:", "Ne12:", _ "Ne13:", "Ne14:", "Ne15:", "Ne16:", _ "LPT1:", "LPT2:", "File:", "SMC100:") 'Setup printer to Print X = 0 TryAgain: On Error Resume Next 'Printer Application.ActivePrinter = myprinter & Prt_On & NetWork(X) If Err.Number < 0 And X < 16 Then X = X + 1 GoTo TryAgain ElseIf Err.Number < 0 And X 15 Then GoTo PrtError End If On Error GoTo 0 NetworkPrinter = myprinter & Prt_On & NetWork(X) errorExit: Exit Function PrtError: 'no printer found NetworkPrinter = "" Resume errorExit End Function --- So the idea here would be that you instead of setting dirrectly the name, invoke this function with just the printer name, but maybe a better approach would be to check for the name in the list of printers. How to get a list of printers? Try analyze this code - you can modify it easily to return the propper name... (from http://www.ozgrid.com/forum/showthread.php?t=20182) --- Sub get_printers() On Error Resume Next Set WshNetwork = CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 To oPrinters.Count - 1 Step 1 Cells(i + 1, 1) = " Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i + 1) Next End Sub --- best regards, Leo "RMS" wrote: I have two shared printers on two seperate hard wired networked, desktop computers. One prints tractor fed labels for Serums, and one prints instructions on regular letter paper. The patient information is entered on a laptop which connects wirelessly to the newtork. I use an Excel Macro assigned to two different buttons to select the proper printer and the range to print. This setup works great....Until I introduce a second laptop, using the same Excel version (2007) and same code. Both laptops access each printer perfectly for printing the "Test Page". However the Printer Macros on one or the other laptops fails to work. If I re-record the marcos they work again. (Manual Printing works fine always) On careful examination of the macro code, I find that the "ne03", for example, has changed to "ne05" in the new code on the printer line. What would be a strategy to avoid having to re-record the macros? Thanks-a very puzzled RMS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2003 printing problem--printing 1 document on 2 pages | Excel Discussion (Misc queries) | |||
Printing problem | Excel Discussion (Misc queries) | |||
Printing Problem | Charts and Charting in Excel | |||
Printing Problem | Excel Discussion (Misc queries) | |||
Printing problem | Excel Discussion (Misc queries) |