|
-
Oct 9th, 2001, 02:13 PM
#1
Thread Starter
New Member
Printer Notification Object!!
This is my code (MACRO )
what my code has to do is that after printing process is over i should open a specified web page , but unfortunately my code is hanging saying operation timed out (i did some mistake but being a new bee i dont know)
Can someone correct mycode in such a way that the page should open after the printing process getsover!!! please help me!!
Sub shan()
'
' shan Makro
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, background:=True, PrintToFile:=True, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
' these are all std stuff found with win32 api
Dim res&
Dim signalflags&
Dim x&
Dim mbres&
mbres = vbOK
Dim prnotify As PRINTER_NOTIFY_INFO
Dim prData As PRINTER_NOTIFY_INFO_DATA
Dim prDefault As PRINTER_DEFAULTS
prDefault.pDatatype = vbNullString
prDefault.pDevMode = 0
prDefault.DesiredAccess = PRINTER_ACCESS_ADMINISTER
If prhandle <> 0 Then Call ClosePrinter(prhandle)
res& = OpenPrinter(1, prhandle, prDefault) '??? what to give here
If res = 0 Then
MsgBox "job printing"
Exit Sub
End If
' Create a notification object that will change
' when a job is added or removed
NotificationObject = FindFirstPrinterChangeNotification(prhandle, PRINTER_CHANGE_JOB, 0, 0)
If NotificationObject = 0 Then
MsgBox "Unable to create notification object"
Exit Sub
End If
Visible = False
' This loop will never exit
Do
res = WaitForSingleObject(NotificationObject, 20000)
If res = WAIT_TIMEOUT Then
mbres = MsgBox("Timed out", vbOKCancel)
Else
res = FindNextPrinterChangeNotification(NotificationObject, signalflags&, 0, 0)
' Now, what happened?
If signalflags And PRINTER_CHANGE_ADD_JOB <> 0 Then
Beep
MsgBox "Job was added"
End If
If signalflags And PRINTER_CHANGE_DELETE_JOB <> 0 Then
Beep
MsgBox "Job was deleted"
End If
End If
Loop While mbres <> vbCancel
Visible = True
' second process starting to open up the archivieren client
'Dim res& --- already defined
Dim obj As Object
Dim strFileName As String
Dim hwnd As Long
strFileName = "http:\\owmsun01\Archivieren\index.html"
res& = ShellExecute(hwnd, "open", strFileName, vbNullString, CurDir$, SW_SHOW)
If res < 32 Then
MsgBox "unable to open ..."
End If
End Sub
***********************************************
Please correct this code i dont need so many msg boxes but just the specified web page should open after the entire printing process gets over)
Last edited by svivek; Oct 10th, 2001 at 02:53 AM.
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|