Problem with formula

M

Mia

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top