A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macros don’t run unattended



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 2nd 09, 01:45 PM posted to microsoft.public.outlook.program_vba
Lionel H
external usenet poster
 
Posts: 7
Default Macros don’t run unattended

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.xl s 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"


  #2  
Old April 2nd 09, 04:09 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Macros don’t 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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Lionel H" wrote in message
...
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.xl s 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"



  #3  
Old April 3rd 09, 01:22 PM posted to microsoft.public.outlook.program_vba
Lionel H
external usenet poster
 
Posts: 7
Default Macros don’t 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


"Ken Slovak - [MVP - Outlook]" 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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
question on rules on unattended mailbox Gary Outlook - General Queries 5 March 16th 09 07:41 PM
Using DBXPRESS for unattended OE Folder Maintenance and Archiving pwrichcreek Outlook Express 4 July 18th 08 03:23 AM
Outlook could not find the requested contact. You don’t have ... MadDog Outlook - Using Contacts 6 October 31st 07 12:07 AM
Automated / Unattended outlook installation harry dass Outlook - Installation 2 July 17th 07 04:54 AM
Unattended Outlook Client Setup Dave Leonardi Outlook - General Queries 0 February 14th 06 03:05 PM


All times are GMT +1. The time now is 05:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.