< návrat zpět

MS Excel


Téma: Vyhledávání síťové tiskárny. rss

Zaslal/a 26.4.2018 12:42

Zdravím.
Vyměnili mi excel z 2007 na 2016 a přestalo mi fungovat makro na vyhledávání síťové tiskárny, které do té doby spolehlivě fungovalo. Nevíte někdo, co je třeba pozměnit, aby to zase fachalo ?

Toto makro má najít pod jakým "on Ne" číslem je konkrétní tiskárna, vytisknout to a přehodit tiskárnu zpět.

Díky.

Sub tisk()

Dim strCurrentPrinter As String, strNetworkPrinter As String
strNetworkPrinter = GetFullNetworkPrinterName("\\czstopc137\zebra")
If Len(strNetworkPrinter) > 0 Then ' found the network printer
strCurrentPrinter = Application.ActivePrinter
' change to the network printer
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut ' print something
' change back to the previously active printer
Application.ActivePrinter = strCurrentPrinter
End If
Range("d4").Select

End sub

-----------------------------------------------------
A definovaná funkce:
-----------------------------------------------------

Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
' returns the full network printer name
' returns an empty string if the printer is not found
' e.g. GetFullNetworkPrinterName("HP LaserJet 8100 Series PCL")
' might return "HP LaserJet 8100 Series PCL on Ne04:"
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 10
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
' the network printer was found
GetFullNetworkPrinterName = strTempPrinterName
i = 10 ' makes the loop end
End If
i = i + 1
Loop
' remove the line below if you want the function to change the active printer
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function

Jméno
Kontrola
Text
  b i u s img code url hr   1 2 3 4 5 6 7 8 9 10

Nebyly zaslány žádné odpovědi.

Uživatelské menu

Nejste přihlášen(a)
avatar\n

Menu

On-line nástroje

Formulář Faktura

Formulář Faktura IV

Oblíbený formulář Faktura byl vylepšen a rozšířen.
Více se dočtete zde.

Aktivní diskuse

Relativní cesta - zdroje Power Query

elninoslov • 25.4. 15:12

Relativní cesta - zdroje Power Query

Alfan • 25.4. 15:08

Relativní cesta - zdroje Power Query

elninoslov • 25.4. 14:21

Relativní cesta - zdroje Power Query

Alfan • 25.4. 10:49

Relativní cesta - zdroje Power Query

elninoslov • 25.4. 10:47

Relativní cesta - zdroje Power Query

Alfan • 25.4. 10:40

Relativní cesta - zdroje Power Query

Alfan • 25.4. 9:44