Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Printer Problem


I am using the Call CopyPrintData(ActiveSheet) to print. There are times
when the printer is offline or defined at remote locations when the call to
CopyPrintData(ActiveSheet) task creates a continues hourglass and will not
complete.

Is there away to build logic if the call CopyPrintData(ActiveSheet) task
takes more than 45 seconds to end the task?

Please help me with logic to resolve this issue.

Thank you vey much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Printer Problem

You could ping the printer by its IP address to determine if it is online

Sub Ping()
Set objPing = GetObject _
("winmgmts:{impersonationLevel=impersonate}"). _
ExecQuery("select * from Win32_PingStatus " & _
"where address = '16.37.100.16'")
For Each objStatus In objPing
If objStatus.StatusCode = 0 Then
MsgBox ("On-Line")
Else
MsgBox ("Off-Line")
End If
Next
End Sub

"Dean P." wrote:


I am using the Call CopyPrintData(ActiveSheet) to print. There are times
when the printer is offline or defined at remote locations when the call to
CopyPrintData(ActiveSheet) task creates a continues hourglass and will not
complete.

Is there away to build logic if the call CopyPrintData(ActiveSheet) task
takes more than 45 seconds to end the task?

Please help me with logic to resolve this issue.

Thank you vey much.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Printer Problem

"Dean P." wrote:


I am using the Call CopyPrintData(ActiveSheet) to print. There are times
when the printer is offline or defined at remote locations when the call to
CopyPrintData(ActiveSheet) task creates a continues hourglass and will not
complete.

Is there away to build logic if the call CopyPrintData(ActiveSheet) task
takes more than 45 seconds to end the task?

Please help me with logic to resolve this issue.

Thank you vey much.


Sub PrinterTest()

'get active printer
strPrinterName = Application.ActivePrinter

'connect to WMI on local computer
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" _
& "root\cimv2")

'enumerate printers
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")

'Printer status:
'1 Other
'2 Unknown
'3 Idle
'4 Printing
'5 Warmup
'6 Stopped printing
'7 Offline

'get active printer status
For Each objPrinter In colInstalledPrinters

If InStr(strPrinterName, objPrinter.Name) Then
Debug.Print objPrinter.Name
Debug.Print "Network printer: " & _
(objPrinter.Local And objPrinter.Network)
If objPrinter.PrinterStatus = 1 _
Or objPrinter.PrinterStatus = 2 Then
Debug.Print "Printer not responding"
Else
Debug.Print "Printer status OK"
End If
End If

Next

End Sub


Hope this helps.

--
urkec
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem printing to HP color printer toodi4 Excel Worksheet Functions 0 January 12th 09 07:36 PM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
printer problem Charlie Excel Discussion (Misc queries) 9 October 21st 06 04:57 PM
Printer problem John Setting up and Configuration of Excel 1 March 21st 06 01:56 AM
Problem sending merge info to printer Boog Excel Programming 0 May 17th 05 04:42 AM


All times are GMT +1. The time now is 03:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"