Login | |
|
 |
RE: Printer Addition - 4/19/2006 11:35:43 AM
|
|
 |
|
| |
scotthawks
Posts: 10
Score: 0
Joined: 4/19/2006
Status: offline
|
i need to mention that these variables are being passed thru a function call here is the entire function with an example call ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Sub: AddPrinterLPT ' ' Purpose: Connect to shared network printer ' ' Input: ' strPrtServerDomain Domain in which print server is a member ' strPrtServer Name of print server ' strPrtShare Share name of printer ' ' Output: ' ' Usage: ' Call AddPrinter ("LPT2", "Mydomain2", "MyPrtSvr2", "Bld1Rm101-HP4050") ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub AddPrinterLPT(strPrtPort, strPrtServerDomain, strPrtServer, strPrtShare) On Error Resume Next DIM strPrtPath 'Full path to printer share Dim objPrinter 'Object reference to printer Dim strMsg 'Message output to user Dim blnError 'True / False error condition Dim strPrinter 'Path to Printer blnError = False 'Build path to printer share ' strPrinter = "\\" & strPrtServer & "\" & strPrtShare strPrtPath = """" & strPrtPort & """, """ & strPrinter & """" Call UserPrompt (strPrtPath) 'Test to see if shared printer exists. 'Proceed if yes, set error condition msg if no. Set objPrinter = GetObject _ ("WinNT://" & strPrtServerDomain & "/" & strPrtServer & "/" & strPrtShare) If IsObject( objPrinter ) AND _ (objPrinter.Name <> "" AND objPrinter.Class = "PrintQueue") Then 'Different mapping techniques depending on OS version If objWshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then Err.Clear 'Map printer objWshNetwork.AddPrinterConnection strPrtPath 'objWshNetwork.AddPrinterConnection "LPT2", "\\Enterprise\ENG_6500" Else 'Mapping printers for Win9x & ME is a pain and unreliable. End If Else blnError = True End IF 'Check error condition and output appropriate user message If Err <> 0 OR blnError = True Then strMsg = "Unable to connect to network printer. " & vbCrLf & _ "Please contact the Helpdesk @ ext 291" & vbCrLf & _ "and ask them to check the " & strPrtServer & " server." & _ vbCrLf & vbCrLf & _ "Let them know that you are unable to connect to the '" _ & strPrtShare & "' printer" objWshShell.Popup strMsg,, "Logon Error !", 48 Else Call UserPrompt ("Successfully added printer connection to " & strPrtPath) End If Set objPrinter = Nothing End Sub the error i get is the strMsg that i have defined.
|
|
| |
|
|
|
|
|