Hi all, I have a code which identifies from which system the code is running and changes the default printer, but for some reason the if part isnt working. Can anyone please help me with this regard.
I was able to identify the computers name with the help of environ function. Mr @RoryA helped me out in this regard .
the code is as follows
Thank you in advance
I was able to identify the computers name with the help of environ function. Mr @RoryA helped me out in this regard .
Identify which computer
Hi all, I have a code which works fine from other computers. But when i use it from the main computer it does not work so can you please help me in identifying which computer the code is running so that i can use that printer Private Sub CommandButton1_Click() Set mynetwork =...
www.mrexcel.com
the code is as follows
VBA Code:
Private Sub CommandButton1_Click()
Dim Computername As String
Set mynetwork = CreateObject("WScript.network")
Computername = Environ$("computername")
If Computername <> "Desktop-165t6df" Then
mynetwork.setdefaultprinter "\\Desktop-165t6df\THERMAL Receipt #1"
ActiveSheet.Range("A3:B52").Select
Selection.PrintOut Copies:=1
mynetwork.setdefaultprinter "\\Desktop-165t6df\HP LaserJet 1020"
Else
mynetwork.setdefaultprinter "THERMAL Receipt #1"
ActiveSheet.Range("A3:B52").Select
Selection.PrintOut Copies:=1
mynetwork.setdefaultprinter "HP LaserJet 1020"
End If
End Sub
Thank you in advance