=?Utf-8?Q?Macros_don=E2=80=99t_run_unattended?=

Status
Not open for further replies.
T

TGlvbmVsIEg

Macros don't run unattended

Software involved is Windows XP/Outlook/Excel 2003

Moving to 2007 is not currently an option.

OL security is set to Low.

All code is self certified.

I use Windows scheduled tasks to start an OL session followed a minute later

by an XL session

If I remain logged in to the computer while the scheduled tasks fire up, the

OL & XL code executes as I expect.

If I log out of the computer before the scheduled tasks fire up, OL code

does not execute at all; XL code executes as far as it can until it hangs

waiting for OL to do something.

A previous discussion item suggests that this can be fixed by inhibiting

splash screens, but wide ranging searches on Google suggest that almost all

splash screens can be inhibited except for the OL splash screen.

The OL code involved is below.

The trace logs for attended and unattended running are below that.

What the XL code does is immaterial to this question.

Can anyone help either with OL splash screen inhibition or any other way of

persuading the OL code to execute in "unattended" mode?

In ThisOutlookSession:

Option Explicit

Dim objX As Object

Private Sub Application_Startup()

Set objX = New olEventClassModule

Log_RB_Trace_Line "I", "Application_Startup", "OL Started"

End Sub

Private Sub Application_Quit()

Set objX = Nothing

Log_RB_Trace_Line "I", "Application_Quit", "OL Ended"

End Sub

In Class Modules olEventClassModule:

Option Explicit

Dim myolApp As New Outlook.Application

Dim myNS As NameSpace

Dim myServerMailbox As Outlook.MAPIFolder

Dim WithEvents myServerMailboxFolders As Outlook.Folders

Private Sub Class_Initialize()

Set myNS = myolApp.GetNamespace("MAPI")

Set myServerMailbox = myNS.Folders("<mailbox name>") 'edited to remove

real name

Set myServerMailboxFolders = myServerMailbox.Folders

End Sub

Private Sub myServerMailboxFolders_FolderChange(ByVal Folder As MAPIFolder)

Log_RB_Trace_Line "I", "myServerMailboxFolders_FolderChange", "OL " &

Folder & " changed"

Select Case Folder

Case "Drafts"

If Folder.Items.Count = 0 Then

Log_RB_Trace_Line "I",

"myServerMailboxFolders_FolderChange", "OL Application Quit"

Application.Quit

End If

Case Else

'do nothing

End Select

End Sub

In Modules M06_Utilities:

Option Explicit

Sub Log_RB_Trace_Line(strLineType As String, strModuleName As String,

strLine As String)

Open "D:\RB_Trace_Log.txt" For Append As #1

Write #1, Now() & " OL: " & strLineType & ": " & strModuleName & ": " &

strLine

Close #1

End Sub

Trace logged by "attended" run

"20/03/2009 16:14:12 OL: I: Application_Startup: OL Started"

"20/03/2009 16:14:40 XL: I: M41_ReCreate_Peak_Status: Start"

"20/03/2009 16:15:06 XL: I: M41_ReCreate_Peak_Status: PeakStatus.xls saved"

"20/03/2009 16:15:06 XL: I: M07_Publish_File_on_ProjectWEB: Start"

"20/03/2009 16:15:06 XL: I: M07_New_Send_olMailItem: Start"

"20/03/2009 16:15:07 OL: I: myServerMailboxFolders_FolderChange: OL Drafts

changed"

"20/03/2009 16:15:07 XL: I: M07_New_Send_olMailItem:

D:\Pathway\XL_Workbooks\ReleaseBoard\PeakStatus.xls Sent"

"20/03/2009 16:15:07 XL: I: M41_ReCreate_Peak_Status: File Published"

"20/03/2009 16:15:07 XL: I: M41_ReCreate_Peak_Status: XL Quit"

"20/03/2009 16:15:26 OL: I: myServerMailboxFolders_FolderChange: OL Drafts

changed"

"20/03/2009 16:15:26 OL: I: myServerMailboxFolders_FolderChange: OL

Application Quit"

"20/03/2009 16:15:31 OL: I: Application_Quit: OL Ended"

Trace logged by "unattended" run

"20/03/2009 16:23:00 XL: I: M41_ReCreate_Peak_Status: Start"

"20/03/2009 16:23:26 XL: I: M41_ReCreate_Peak_Status: PeakStatus.xls saved"

"20/03/2009 16:23:26 XL: I: M07_Publish_File_on_ProjectWEB: Start"

"20/03/2009 16:23:26 XL: I: M07_New_Send_olMailItem: Start"
 
=?Utf-8?Q?Re:_Macros_don=E2=80=99t_run_unattended?=

What do you mean by "remain logged into the computer"? Do you mean logging

off the Windows logon session? If so just don't do that.

Where is the code in the Class Modules olEventClassModule, is it in the

Outlook VBA project? If so do not use New Outlook.Application, use the

intrinsic Outlook.Application object Application instead.

"Lionel H" <LionelH> wrote in message

news:92FF5779-7760-4CFF-9324-5315CD47ABB3@microsoft.com...
> Macros don't run unattended

> Software involved is Windows XP/Outlook/Excel 2003
> Moving to 2007 is not currently an option.
> OL security is set to Low.
> All code is self certified.
> I use Windows scheduled tasks to start an OL session followed a minute
> later
> by an XL session

> If I remain logged in to the computer while the scheduled tasks fire up,
> the
> OL & XL code executes as I expect.
> If I log out of the computer before the scheduled tasks fire up, OL code
> does not execute at all; XL code executes as far as it can until it hangs
> waiting for OL to do something.

> A previous discussion item suggests that this can be fixed by inhibiting
> splash screens, but wide ranging searches on Google suggest that almost
> all
> splash screens can be inhibited except for the OL splash screen.

> The OL code involved is below.
> The trace logs for attended and unattended running are below that.
> What the XL code does is immaterial to this question.

> Can anyone help either with OL splash screen inhibition or any other way
> of
> persuading the OL code to execute in "unattended" mode?

> In ThisOutlookSession:

> Option Explicit
> Dim objX As Object

> Private Sub Application_Startup()
> Set objX = New olEventClassModule
> Log_RB_Trace_Line "I", "Application_Startup", "OL Started"
> End Sub

> Private Sub Application_Quit()
> Set objX = Nothing
> Log_RB_Trace_Line "I", "Application_Quit", "OL Ended"
> End Sub

> In Class Modules olEventClassModule:

> Option Explicit

> Dim myolApp As New Outlook.Application
> Dim myNS As NameSpace
> Dim myServerMailbox As Outlook.MAPIFolder
> Dim WithEvents myServerMailboxFolders As Outlook.Folders

> Private Sub Class_Initialize()
> Set myNS = myolApp.GetNamespace("MAPI")
> Set myServerMailbox = myNS.Folders("<mailbox name>") 'edited to remove
> real name
> Set myServerMailboxFolders = myServerMailbox.Folders

> End Sub

> Private Sub myServerMailboxFolders_FolderChange(ByVal Folder As
> MAPIFolder)

> Log_RB_Trace_Line "I", "myServerMailboxFolders_FolderChange", "OL " &
> Folder & " changed"

> Select Case Folder
> Case "Drafts"
> If Folder.Items.Count = 0 Then
> Log_RB_Trace_Line "I",
> "myServerMailboxFolders_FolderChange", "OL Application Quit"
> Application.Quit
> End If
> Case Else
> 'do nothing
> End Select
> End Sub

> In Modules M06_Utilities:

> Option Explicit

> Sub Log_RB_Trace_Line(strLineType As String, strModuleName As String,
> strLine As String)

> Open "D:\RB_Trace_Log.txt" For Append As #1
> Write #1, Now() & " OL: " & strLineType & ": " & strModuleName & ": " &
> strLine
> Close #1

> End Sub

> Trace logged by "attended" run

> "20/03/2009 16:14:12 OL: I: Application_Startup: OL Started"
> "20/03/2009 16:14:40 XL: I: M41_ReCreate_Peak_Status: Start"
> "20/03/2009 16:15:06 XL: I: M41_ReCreate_Peak_Status: PeakStatus.xls
> saved"
> "20/03/2009 16:15:06 XL: I: M07_Publish_File_on_ProjectWEB: Start"
> "20/03/2009 16:15:06 XL: I: M07_New_Send_olMailItem: Start"
> "20/03/2009 16:15:07 OL: I: myServerMailboxFolders_FolderChange: OL
> Drafts
> changed"
> "20/03/2009 16:15:07 XL: I: M07_New_Send_olMailItem:
> D:\Pathway\XL_Workbooks\ReleaseBoard\PeakStatus.xls Sent"
> "20/03/2009 16:15:07 XL: I: M41_ReCreate_Peak_Status: File Published"
> "20/03/2009 16:15:07 XL: I: M41_ReCreate_Peak_Status: XL Quit"
> "20/03/2009 16:15:26 OL: I: myServerMailboxFolders_FolderChange: OL
> Drafts
> changed"
> "20/03/2009 16:15:26 OL: I: myServerMailboxFolders_FolderChange: OL
> Application Quit"
> "20/03/2009 16:15:31 OL: I: Application_Quit: OL Ended"

> Trace logged by "unattended" run

> "20/03/2009 16:23:00 XL: I: M41_ReCreate_Peak_Status: Start"
> "20/03/2009 16:23:26 XL: I: M41_ReCreate_Peak_Status: PeakStatus.xls
> saved"
> "20/03/2009 16:23:26 XL: I: M07_Publish_File_on_ProjectWEB: Start"
> "20/03/2009 16:23:26 XL: I: M07_New_Send_olMailItem: Start"

>
 
=?Utf-8?Q?Re:_Macros_don=E2=80=99t_run_unattended?=

Ken,

Being logged in or out of the computer is a red herring - which is

fortunate, because that is a story the technicalities of which would very

quickly defeat me.

Your advice about using the intrinsic Outlook.Application object Application

did the trick " thank you, I would not have got there without it.

XL hanging had nothing to do with OL hanging, and if my XL error management

had been more robust, I'd have known that. Still it goes some way to

explaining why I've taken so long to get back to you.

Once again, many thanks.

Lionel
wrote:


> What do you mean by "remain logged into the computer"? Do you mean logging
> off the Windows logon session? If so just don't do that.

> Where is the code in the Class Modules olEventClassModule, is it in the
> Outlook VBA project? If so do not use New Outlook.Application, use the
> intrinsic Outlook.Application object Application instead.

> >

>

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C Outlook Changing Sent Message Headings to SPAM =?UTF-8?B?4Liq4Lij4LmJ4L Using Outlook 1
S Outlook 2007, UTF-8 & national characters Using Outlook 5
Z =?Utf-8?Q?How_to_add_appointment=E2=80=99s_non-sen?==?Utf-8?Q?dable_recipients_programmaticall?==?Ut Outlook VBA and Custom Forms 5
S Why do I have to close and reopen Outlook for macros to work? Outlook VBA and Custom Forms 2
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
V Outlook macros no longer run until VB editor is opened Outlook VBA and Custom Forms 0
D Outlook 2013 Macros only run in VB editor, not in drop down or button Outlook VBA and Custom Forms 14
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
nathandavies Email Details to Excel & Save as .MSG on one macro - combination of 2 macros Outlook VBA and Custom Forms 3
N Export details to a excel spreadsheet using macros Using Outlook 0
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
N Does a Shared Folder Policy override a Digital Signature Setting for macros? Outlook VBA and Custom Forms 6
A Processing Incoming E-mails with Macros Using Outlook 0
Diane Poremsky Block Macros in Office 2013/2016 Using Outlook 0
Diane Poremsky Using Arrays in Outlook macros Using Outlook 0
Diane Poremsky Running Outlook Macros on a Schedule Using Outlook 0
B Choose commands from Macros is empty Outlook VBA and Custom Forms 3
P Macros in Word 2003 - how to transfer to another Word 2003? Using Outlook 1
N Running multiple macros upon sending Outlook VBA and Custom Forms 6
Britonius Macros for Delegate Issues? Using Outlook 9
S Using Macros in the Outlook Calendar Using Outlook 2
A Outlook 2010 disabled macros Using Outlook 2
R Outlook Macros for Appointments and Tasks Using Outlook 1
M Running macros in tasks sent out as meeting requests in invitees machine Using Outlook 4
L Calendar Macros? Using Outlook 3
S Inserting Dates With Quick Parts (or Macros) Using Outlook 4
L Macros disabled in custom Outlook form Outlook VBA and Custom Forms 1
V Run multiple Macros or macros from within other macros ? Outlook VBA and Custom Forms 2
P Macros Do Not Run Outlook VBA and Custom Forms 1
C Why can't 2003 handle the macros I wrote for 2000 Outlook VBA and Custom Forms 6
M macros of outlook 2007 Outlook VBA and Custom Forms 1
B Macros have been disabled error Message with Custom forms Outlook VBA and Custom Forms 17
C Create macros in Outlook 2007 Outlook VBA and Custom Forms 5
S Need: Date handling in Outlook Macros, either information/documentation Outlook VBA and Custom Forms 1
V Macros suddenly disabled Outlook VBA and Custom Forms 1
N Copying outlook macros between pcs Outlook VBA and Custom Forms 1
D Macros Disabled in Outlook 2007 BCM (Business Contact Manager) 9
C Outlook macros have vanished Outlook VBA and Custom Forms 1
Y How to record macros in Outlook2007? Outlook VBA and Custom Forms 1
L Digital signing macros Outlook VBA and Custom Forms 1

Similar threads

Back
Top