macro runs slower on startup than after

Vash

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
Hi all,

Apologies, but there may be two parts to this question..

In Outlook 2010, I cobbled together a macro from a series of code snippets and some of my own volition, and everything "works" (subjective term).

Basically the macro constructs a calendar and adds appointments from a group of users calendars who've tagged selected appointments with a certain category. I don't have issues with the macro itself (at least I don't think so...), my questions are relating to running this macro at start-up, and possibly about some changes between Outlook 2010 and 2016.

First, running the macro from the Outlook VB editor, the code takes ~9 seconds to run (Timer calls at start and end). This is about the same for Office 2010 and 2016.

I have also configured the macro to run on Application_Startup() -- well in a round about way from code I must admit I don't quite fully understand all the mechanics/implications of:
Rich (BB code):
Private Sub Application_Startup()
    Debug.Print ("Starting Handler: " & Time)
    mySyncInstance.Initialize_handler
End Sub
And then I have a Class module:
Rich (BB code):
Sub Initialize_handler()
 Set mySync = Application.Session.SyncObjects.Item(1)
 mySync.Start
End Sub

Private Sub mySync_SyncEnd()
Call makeGroupCalendar
End Sub
And another module with the actual makeGroupCalendar() code.

I forget why I went/needed to go this SyncObject route - I think it was something about making sure I had fully connected to the exchange server before trying to access members calendars. But, the end result is what I want, the macro is ran automatically on start-up and builds the calendar.

However, looking at the VBE Immediate Window after start-up, the macro takes ~25 seconds to run. I get that on start-up there are probably lots of things that need to happen, and the code has DoEvents within the loop to keep Outlook 'responsive' while the macro is running.

Now, in Outlook 2010, this wasn't such an issue, the DoEvents seemed to 'do their job' and Outlook was still responsive (a little laggy, but usable while macro ran). In Outlook 2016, it is unworkable. It's as if the DoEvents aren't honored, and the entire Outlook locks-up for the 25 seconds while the macro runs.

So, has anything changed in the use of DoEvents between 2010 and 2016? Can anyone suggest a reason why code that runs in ~9 seconds manually after start-up takes ~25 seconds on start-up?

Cheers
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I don't know if Michael is around - he could answer this better than I could. As far as I know, nothing changed that should change how doevents works.

For what it's worth, I would probably do something to trigger it after outlook is up and running - maybe trigger it by a reminder.
 

Vash

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
Thanks Diane, I think at one stage I looked into triggering on reminders in Outlook 2010, but never made the switch. I’m trying to make this as un-obtrusive for a group of users to use - but then change to Outlook 2016 has made this unworkable!

cheers
 

Vash

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
I don't know if Michael is around - he could answer this better than I could. As far as I know, nothing changed that should change how doevents works.

For what it's worth, I would probably do something to trigger it after outlook is up and running - maybe trigger it by a reminder.
I've now made this trigger on a reminder (following Running Outlook Macros on a Schedule but creating a Task instead of Appointment). It seems regardless of how long I choose to delay the code execution after start up, the first time the calendar macro is run it takes 25 seconds, and subsequent re-runs take 9 seconds.

Still no luck with DoEvents, while macro is running I cannot select new mail and have the preview load in the reading pane?
 
Thread starter Similar threads Forum Replies Date
J Macro only runs within VBA Editor Outlook VBA and Custom Forms 2
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
G VBA Macro Calendar Printing Assistant 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
R Macro Schedule every day in Outlook Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
D.Moore Folder view settings by VBA macro Outlook VBA and Custom Forms 57
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
V Outlook Macro to show Flagged messages Outlook VBA and Custom Forms 2
O Run macro automatically at sending an email Using Outlook 11
R Retain Original Message When Forwarding With Macro Outlook VBA and Custom Forms 3
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
O Macro - paste as plain text Outlook VBA and Custom Forms 2
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
witzker Macro to set contact reminder to next day 9:00 Outlook VBA and Custom Forms 45
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
E Copying data from e-mail attachement to EXCEL file via macro Outlook VBA and Custom Forms 38
M Macro to add date/time stamp to subject Outlook VBA and Custom Forms 4
R VBA macro - new message Outlook VBA and Custom Forms 3
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
S Macro using .SendUsingAccount only works the first time, after starting Outlook Outlook VBA and Custom Forms 4
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
B VBA Macro for assigning multiple Categories to an email in my Inbox Outlook VBA and Custom Forms 1
N Macro for attachment saved and combine Outlook VBA and Custom Forms 1
Sabastian Samuel HOW DO I FORWARD AN EMAIL WITH MACRO using an email that in the body of another email Outlook VBA and Custom Forms 3
C Search with Google Macro? Outlook VBA and Custom Forms 4
J Outlook 2013 Extract Flag Completed dates to Excel Macro Outlook VBA and Custom Forms 16
M Slow VBA macro in Outlook Outlook VBA and Custom Forms 5
D Print Attachments only in selected emails using a macro Outlook VBA and Custom Forms 3
M Macro for attachments download adjustment Outlook VBA and Custom Forms 3
M VBA macro for Inbox's attachments search Outlook VBA and Custom Forms 0
B Macro to manually move selected emails to network folder Outlook VBA and Custom Forms 1
A Forward Outlook Email by Filtering using Macro Rule Outlook VBA and Custom Forms 44
I Dialog called up multiple times when saving emails from macro Outlook VBA and Custom Forms 2
Y VBA Macro to highlight some Keyword in mail body? Outlook VBA and Custom Forms 3
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
D Outlook macro with today's date in subject and paste clipboard in body Outlook VBA and Custom Forms 1
nathandavies Email Details to Excel & Save as .MSG on one macro - combination of 2 macros Outlook VBA and Custom Forms 3
C Outlook Subject Line Macro Outlook VBA and Custom Forms 0
B Automation error running VB macro code Outlook VBA and Custom Forms 8
J Is this possible to do with a macro? Outlook VBA and Custom Forms 17
Similar threads


















































Top