Re: Force Macro to Wait Until New Message Displayed and Printed

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Chris,

in general I´d say, you need a control, that fires an event if the
document is fully loaded. In VB I´d probably use the DHTMLEdit control,
but AFAIK you can´t use it on a MSForms Formular.

Please search in your available components, maybe there is the
"Microsoft Webbrowser" e.g. You could then save the mails as HTML files,
load it into the control and print.

--
Viele Grüße
Michael Bauer - MVP Outlook


<chrisf84540@xxxxxxxxx> wrote in message
news:1112993424.079808.80430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I use this macro to print all new incoming messages. I use Outlook
> 2002. Since the messages are html and contain images, this macro
> displays then prints each message. This accomodates an Outlook 2002
> requirement that incoming messages be displayed prior to printing.
>
> Problem is, if messages arrive more frequently then, say, 1 minute,
the
> macro will just process one incoming message, but leave other incoming
> messages unprocessed. Otherwise, it works great.
>
> I don't want to have to increase the delay; right now it delays 15
> seconds after displaying, and 15 seconds after printing; I guess that
> is not enough time in some cases.
>
> Often, we get the Outlook message, ""Items in this message are still
> loading. Please wait a moment and then try again."
>
> I need to force the macro to wait until each item is fully displayed
> and printed prior to attempting to process another item. I also would
> want to make sure that ALL unread items in the inbox are processed in
> case one gets missed.
>
> Thanks,
> Chris
>
> Here is the code, and it runs in the ThisOutlookSession module:
> ----------------------------------------------------------------------
-
>
> Option Explicit
>
> Private WithEvents olInboxItems As Items
> Private Sub Application_Startup()
> Dim objNS As NameSpace
> Set objNS = Application.GetNamespace("MAPI")
> ' instantiate objects declared WithEvents
> Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
> Set objNS = Nothing
> End Sub
>
> Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
> On Error Resume Next
>
> Dim PauseTime, Start, Finish, TotalTime
> If ISLIKE(Item.Subject, "Online Order*") = True Then
> Item.Display
> 'here are your three choices about window state...
> 'Application.ActiveWindow.windowstate 0 = maximized
> 'Application.ActiveWindow.windowstate 1 = minimized
> 'Application.ActiveWindow.windowstate 2 = normalwindow
> Application.ActiveWindow.WindowState = 1
> 'pause 5 seconds after display before printing to avoid message
> 'timer
> 'Dim PauseTime, Start, Finish, TotalTime
> PauseTime = 15 ' Set duration.
> Start = Timer ' Set start time.
> Do While Timer < Start + PauseTime
> DoEvents ' Yield to other processes.
> Loop
> Finish = Timer ' Set end time.
> Item.PrintOut
> 'timer
> 'Dim PauseTime, Start, Finish, TotalTime
> PauseTime = 15 ' Set duration.
> Start = Timer ' Set start time.
> Do While Timer < Start + PauseTime
> DoEvents ' Yield to other processes.
> Loop
> Finish = Timer ' Set end time.
> Item.Close (olSave)
> Set Item = Nothing
> End If
> End Sub
>

.



Relevant Pages

  • Re: Data Validation
    ... If you still receive the error message that says you cannot access the TEXT property unless the control has the focus, then you must have included the Text property in your expression. ... blank text fields are displayed instead of displaying ... Private Sub Form_BeforeUpdate ...
    (microsoft.public.access.formscoding)
  • Re: In Access 2003, do not allow users to change value of a field
    ... On a form you can lock the control that is displaying the value of a field. ... You can use the on current event along with the form's new record property ... Private Sub Form_Current ...
    (microsoft.public.access.modulesdaovba)
  • Re: Another workaround
    ... This morning I entered a DatePicker control titled "Start date," to plain ... Private Sub Document_ContentControlOnExit(ByVal ContentControl As ... Private Sub Document_ContentControlOnEnter ... MsgBox oCC.Title & "OnExit Event fired." ...
    (microsoft.public.word.vba.general)
  • Re: Another workaround
    ... This morning I entered a DatePicker control titled "Start date," to plain ... Private Sub Document_ContentControlOnExit(ByVal ContentControl As ... Private Sub Document_ContentControlOnEnter ... MsgBox oCC.Title & "OnExit Event fired." ...
    (microsoft.public.word.vba.general)
  • Re: Another workaround
    ... This morning I entered a DatePicker control titled "Start date," to plain ... Private Sub Document_ContentControlOnExit(ByVal ContentControl As ... Private Sub Document_ContentControlOnEnter ... MsgBox oCC.Title & "OnExit Event fired." ...
    (microsoft.public.word.vba.general)