+ Reply to Thread
Results 1 to 6 of 6

Help me fix attached code (create Outlook email then create calendar item)

  1. #1
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Help me fix attached code (create Outlook email then create calendar item)

    Hi,
    I have tested each of the two 'Tasks' below in individual macros and they both work just fine; individually. When I combine them in to one macro, I get an error on line 33. Can anyone tell me why, and how to fix it?

    I don't know a lot about writing code, so please be simplistic. Thanks in advance for the help!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Help me fix attached code (create Outlook email then create calendar item)

    Hi there,

    Does your code have a Reference set to Microsoft Outlook nn.0 Object Library (where nn is the version of Outlook that you're using)?

    In the VBA Editor select Tools > References > Microsoft Outlook nn.0 Object Library

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: Help me fix attached code (create Outlook email then create calendar item)

    Hi,
    I have no idea what any of that means; sorry.

    All I know is that when I take lines 1-32 and put them in their own macro, it creates an email just like intended. When I put lines 33-47 in their own macro, it creates an Outlook appointment just as intended. However, when put both things together in one macro, I get an error on line 33.

    I think it may have something to do with the fact that both sets of code have "Dim" at the start, and perhaps excel doesn't like that or something.

  4. #4
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: Help me fix attached code (create Outlook email then create calendar item)

    Quote Originally Posted by Greg M View Post
    Hi there,

    Does your code have a Reference set to Microsoft Outlook nn.0 Object Library (where nn is the version of Outlook that you're using)?

    In the VBA Editor select Tools > References > Microsoft Outlook nn.0 Object Library

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Okay,okay, okay; you were 100% correct.

    I had a test spreadsheet that had the "create Outlook Calendar Item" macro on it, and it worked fine. Then, when I copied the code to the new spreadsheet, it didn't work.

    I then figured out what you were talking about, took a look, and there was a box that was unchecked "Microsoft Outlook 14.0 Object Library" (see image)

    Untitled.png

    I checked the box, and it worked.
    It's funny because the box was not checked and I could create emails no problem, but not for calendar items.

    Thanks for point out the obvious, even though it was not obvious to me!!!

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    The first part of the code uses late binding the second uses early binding

    Early binding requires the reference, late doesn't.
    If posting code please use code tags, see here.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Help me fix attached code (create Outlook email then create calendar item)

    Hi again,

    Many thanks for taking the trouble to give me your feedback on this.

    Glad to hear that everything is working correctly for you now

    Thanks also for the Reputation increase you gave me!

    Best regards,

    Greg M
    Last edited by Greg M; 11-19-2013 at 08:19 PM. Reason: Added: Thanks for Reputation increase

+ 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] Macro to create a pdf and attach to an email (Outlook)
    By jsedore in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-01-2013, 03:16 PM
  2. Create outlook email from details in cell.
    By lukefallon in forum Excel General
    Replies: 1
    Last Post: 09-10-2012, 05:50 AM
  3. Can't Create Macro for Excel to Email through Outlook
    By grosh83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2012, 05:50 PM
  4. Create reminders in Outlook calendar
    By DKS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2006, 07:25 AM
  5. How do I get excel to create an email using Outlook?
    By cleslie in forum Excel General
    Replies: 0
    Last Post: 11-29-2005, 08:15 PM

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