+ Reply to Thread
Results 1 to 12 of 12

Can't Get Code to Run

  1. #1
    Registered User
    Join Date
    05-24-2020
    Location
    USA
    MS-Off Ver
    2016
    Posts
    3

    Question Can't Get Code to Run

    I am just starting out with Macros -- have never had to do this before. Even though I copy/paste the following macro into ThisOutlookSession, when I hit play, it brings up the Macros dialog box (with run, cancel, step intro) and there is nothing to select there. I am missing a step somehow. What am I doing wrong?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    Hi, welcome to the forum.
    I suggest you review your request 'Can't Get Code to Run' with the application you're working with, it only becomes clear when you read the post but guessing is not an option.
    Be precise and explain what you want.
    You expect us to read the bit of macro code and guess what you're wanting to do, well, that's not really an option.

    My guess is that you want to defer delivery of mail before 7 AM to 7 AM and all after 6 PM to the next day at 7, is this correct?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    05-24-2020
    Location
    USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Can't Get Code to Run

    Thanks for your response.... For some reason, Outlook wasn't invoking the script until I rebooted my computer (I had restarted Outlook). Sorry for invading the board...

    If an administrator woudl like, they may delete this entire thread.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    You're not invading the board, you should just formulate your questions correctly, don't leave it to guessing.
    Re read it yourself without knowing what's about and then see if it's clear, that is all I'm saying.
    If you want your post deleted that's your problem to take care of, we're just a bunch of guys that like to help where we can

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    I would suggest you try this code, minor changes to yours:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-24-2020
    Location
    USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Can't Get Code to Run

    Since you seem to have a handle on my issue... I'm going to post some additional code... You might have some ideas... I do thank you for responding.

    This is for an Microsoft Outlook 2016 macro. I have a boss who has asked me not to send routine emails on the weekend or off hours. My problem is I am a volunteer for this large organization and my volunteering time is second shift and weekends because I work a traditional first shift. His requirements:
    A. Weekdays - do not send mail between 6PM and 8AM.
    B. Weekends - do not send mail
    C. Holidays - do not send mail.

    I was starting off from Diane Poremsky's code at <UGH>forum is preventing me from posting the link

    This does almost everything that I want, with the exception of 2 things.
    (1) I am allowed to send emergency email (I respond to home fires to assist clients -- we need to send out a message stating that during no-email times. (Could I click a "Quick Button" in the toolbar that points to a macro to immediately send emergency messages?... what would that macro be?)
    (2) I need to adjust the script so that I am not sending emails out on a holiday. I would be willing to edit code to allow for those dates each year.

    I'm not sure how I would accomplish that. Here is the full code that I was using that got me to a good place in A. and B. above. C causes problems... and exception #1 and #2... I'm just not sure what to do.

    Diane's Code:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    You've got many more wishes than your first post indicated.
    How's your macro (VBA) knowledge.
    You see, you will have to think up some tricks to be able to send what you call emergency mails which could work if you send those mail messages using a macro button in your Outlook QAT
    The holidays, well you'll need a list of official holidays which is dynamic, that is the year is based on the current date's year
    Fot variable holidays, and that is like Easter, Martin Luther King day you'll need some code that calculates the x weekday of the y month for the z year
    And then there's the code for outside office hours. That I already gave you.
    BTW DON'T use the textual Dayname just weekday(date), 1=Sunday, 2= Monday etc...

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    Well, except for the Holidays and Emergency mails you can start with this
    You will notice that there is an extra ElseIf to check if it's a Friday after 6PM, the it cannot defer to the next day but 3 days further (the Monday)

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    Check this link here, (and there are more)
    https://www.rondebruin.nl/win/s1/outlook/tips.htm

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    I think the part for emergencies will work too, just missing the Holidays, but then that's good practice for you to try and find the way to do it, place both codes below in the ThisOutLookSession module

    Please Login or Register  to view this content.

    Now you need to add a button on your QAT and link the macro SendEmergency to it.
    If you now create a new mail message and write it (don't send it just complete writing it) and then click the new button it will be sent with high Priority (Emergency) and this overules the weekends time s etc, it just sends the mail with high priority
    Last edited by Keebellah; 05-24-2020 at 05:19 PM.

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    I was thinking what you really mean with "Can't Get code to Run"
    Does this mean that the macro does not run at all?
    Have you checked under Options Trust Center - Trust Setting under Macro Settings?
    Attached Images Attached Images

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,904

    Re: Can't Get Code to Run

    Well, have you checked? Tested?

+ 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] Code to display text & code in a combo list, but display only code when selected
    By kdestef1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2019, 06:07 PM
  2. [SOLVED] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  3. [SOLVED] Pattern Building VBA Code - Working code, would like to use cleaner code
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2015, 03:05 PM
  4. [SOLVED] Excel VB code. Message pops up while code running asking question. Code must not wait.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2014, 06:10 AM
  5. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  6. Replies: 2
    Last Post: 03-09-2013, 04:30 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