+ Reply to Thread
Results 1 to 3 of 3

Storing a value between Runs of a macro

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,958

    Storing a value between Runs of a macro

    I thought I had posted this yesterday, but I can't find it.

    I have a macro in Outlook that monitors a "heartbeat" from a reporting system and alerts IT maintenance people in an escalating fashion when the system has been down for 30, 60 and 120 minutes.

    The way it works is that the reporting system sends an email to a common mailbox every 15 minutes with the key word, "Heartbeat" in the subject. A filter rule shuttles this to a specific folder that is monitored by this macro. The macro opens the mailbox periodically. If there is no mail, it goes back to sleep. If there is mail, it gets the dates sent and writes them to a log file (an Excel spreadsheet). The Excel spreadsheet computes the difference between NOW() and the latest sent time in minutes.

    The macro reads this figure and triggers an alert if over 30 minutes and no "level 1" alerts have already been issued. It writes "1" to a cell in the Excel Logbook. So when it wakes up again 5 minutes later, it doesn't send another level 1 alert. At 60 minutes a similar process happesn and the logged alert level is now set to to 2 and the same thing happens at level 3 at 120 minutes.

    If anywhere along the line, the system is fixed then a new message comes in with a recent date stamp, the alert level is set back to zero and the heartbeat monitor is reset.

    I have this working as a prototype using Excel to launch the macro. I anticipate that I can port it to Outlook without issue.

    I am wondering if there is a way to do away with the Excel Log file and somehow store the latest send date and alert level in Outlook.

    Attached is my Excel prototype. Email addresses were changed to protect the innocent.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,614

    Re: Storing a value between Runs of a macro

    Have you considered using SaveSetting/GetSetting to store/retrieve the value in/from the Registry.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,958

    Re: Storing a value between Runs of a macro

    Not at all, considering that I had no idea that such a capability existed .

    Yes, I do get the general idea. Create an registry entry for each of the two values then read them and update them.

    I am very cautious about playing with the registry. Let me do some research on what you are proposing - I can always do a registry backup before experimenting with it. .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Calculating winning/drawing/losing runs & goal scoring runs
    By gko_87 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-25-2017, 06:47 AM
  2. [SOLVED] Macro runs quick initially then bogs down after a few runs
    By pongmeister in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-19-2017, 02:02 PM
  3. Replies: 3
    Last Post: 09-09-2014, 08:29 AM
  4. Storing a VBA Macro for future use
    By birdoo2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-06-2014, 03:28 PM
  5. Calling Macro from another macro and storing result
    By mstuj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2010, 01:12 PM
  6. Storing VB Code in a variable withing a Macro
    By reclmaples in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-02-2009, 11:45 AM
  7. Storing Record As String Macro
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-18-2008, 04:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1