ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with formula (https://www.excelbanter.com/excel-programming/428916-problem-formula.html)

Mia

Problem with formula
 
Hello,

For aprx. 1 year ago i got help with printing formula. Now I have bought
new computers and it don´t work. Do anyone know what could happend?

My formula is:

Sub menyskrivoffert()
'
' menyskrivoffert Makro


UserForm2.Show
If canc = 1 Then Exit Sub


Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server\NRG DSc428 Färg")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter


' change to the network printer


ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
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 & " på 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


BR
Mia



Per Jessen

Problem with formula
 
Hi Mia

Has the printer been installed on the new computer?

//Per

"Mia" skrev i meddelelsen
...
Hello,

For aprx. 1 year ago i got help with printing formula. Now I have bought
new computers and it don´t work. Do anyone know what could happend?

My formula is:

Sub menyskrivoffert()
'
' menyskrivoffert Makro


UserForm2.Show
If canc = 1 Then Exit Sub


Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server\NRG DSc428
Färg")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter


' change to the network printer


ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
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 & " på 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


BR
Mia





All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com