+ Reply to Thread
Results 1 to 14 of 14

Changing vba coding to outlook.

  1. #1
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Changing vba coding to outlook.

    Hi I found some code online that automatically updates outlook with appointments in excel. However for some reason it doesn't recognize the following:

    .
    Please Login or Register  to view this content.
    if I deleted those parts it updates the calendar but obviously I'd like to be able to add them back in.

    The other issue it works fine on my main calendar but if I change the name of the calendar to another calendar i've created it doesn't do anything. No errors just never sends it to outlook.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    Tested and works fine on my end.

    It actually added appointment to each of my calendars (I have 3 set up in Outlook).

  3. #3
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    How strange, thanks for trying. Is it anything to do with the fact I have excel 2007 and outlook 2010?

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    Excel version has little relevance here. I'd guess if it is version issue, then it's Outlook version.

    I tested on Outlook 2016. So, code may need modification for Outlook 2010.

    May be try the code found in link and adopt it to your need. (Note that code in link requires reference to Microsoft Outlook Object Library as is. You could rewrite it to late bind with CreateObject()).
    https://blogs.msdn.microsoft.com/bru...ok-from-excel/

  5. #5
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    Hi thanks, really don’t have a great deal of knowledge with Vba how would I change it to late bind with create object?

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    You can see example in link.
    http://excelmatters.com/2013/09/23/v...-late-binding/

    Basically declare variable not as specific object (i.e. Outlook.Application), but declare it as Object. And then Set it using CreateObject() or GetObject().

    FYI - The code you had in your workbook is late bound.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  7. #7
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    Hi so I got pretty far with this I can now add the data to my calendar however I have access to 2 mail boxes at work and I can't change the default Name of the calendar to anything but calendar. If I leave the excel sheet with "Calendar" it send's it to
    both calender's in each mail box. Any ideas how to distinguish between the two.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    It depends on your Outlook folder structure. See if you can adopt various methods outlined in link.
    https://www.slipstick.com/developer/...tlook-folders/

  9. #9
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    haha thanks just found that and managed to get it to work

    Right next issue is, I want it to delete all the entries in the specific calendar first and then use the macro we created to add the entries back in.
    Last edited by Throughstream; 09-11-2018 at 08:38 AM.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    So assuming olCal is your calendar folder...
    Something like...
    Please Login or Register  to view this content.
    You need to loop from largest index to lowest, as you delete mail item. Since index is reassigned after delete/remove operation.

    Alternately you may be able to check for olItems(i).Class = 26 (olAppointment), rather than TypeName().
    Last edited by CK76; 09-11-2018 at 08:49 AM.

  11. #11
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    ummm yea so I'm guna say I've only got so far with pure luck . SO most of what you're saying is going way over my head

    My code so far is:

    Please Login or Register  to view this content.

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    So in your code, you have If olCal.Name = strCalendar Then ... This is where you check that Outlook.Folder object is Calendar folder.

    If you'd want to first delete "ALL" appointments in it, prior to adding appointments via code...
    Add the code I posted in #10 just below that line.

  13. #13
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Changing vba coding to outlook.

    Perfect thank you!!!

  14. #14
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing vba coding to outlook.

    You are welcome and thanks for the rep

    If this solved your question, please mark the thread as solved by using Thread tool found at the top of your initial post.

+ 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. Outlook to Excel VBA Coding Error
    By eman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2018, 08:16 PM
  2. VBA coding in Outlook 2010 to save attachments from emails
    By Ravipoojari in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2015, 05:28 AM
  3. MS Outlook - VBA Coding Request for Monitoring Ftp Servers
    By ganeshinscribe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2012, 10:03 AM
  4. MS Outlook - VBA Coding Request for Monitoring Ftp Servers
    By ganeshinscribe in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 07-05-2012, 05:57 AM
  5. VBA coding for sending email from excel with the help of outlook
    By NASIR KHAN in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2012, 07:17 PM
  6. Coding with Outlook Web App
    By JHCross in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2011, 08:45 AM
  7. Outlook & SubFolders coding
    By MSweetG222 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2006, 08:45 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