How to create a Outlook calendar entry from a date in Excel using VBA...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LizSmart
    New Member
    • Oct 2012
    • 2

    #1

    How to create a Outlook calendar entry from a date in Excel using VBA...

    Hello -

    disclaimer - I'm a super-novice at VBA -

    I have VBA code that I found on the internet to create a calendar appointment entry in Outlook. I'm trying to modify this code so that the date of the calendar entry is obtained from cell D3 in my Excel spreadsheet - instead of being hard coded into the VBA. Initiatlly cell D3 was formatted as a date, but since I couldn't get that to work, I converted it to text (#12/2/2012#)

    Can anyone help me find a way to getthe date value for the calendar entry from Excel?

    Here is my code:

    Code:
    Dim objOL 'As Outlook.Application
            Dim objAppt 'As Outlook.AppointmentItem
            Dim nDate As String
            Const olAppointmentItem = 1
            Const olMeeting = 1
            Const olFree = 0
                    Range("d3").Select
                    nDate = ActiveCell
            Set objOL = CreateObject("Outlook.Application")
            Set objAppt = objOL.CreateItem(olAppointmentItem)
            objAppt.Subject = "Holiday 1"
            objAppt.Start = nDate
            objAppt.AllDayEvent = True
            objAppt.BusyStatus = 3
            objAppt.Save
            Set objAppt = Nothing
            Set objOL = Nothing
    Last edited by Rabbit; Oct 23 '12, 08:00 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Did you try using the CDate() function to convert the string to a date?

    Comment

    • LizSmart
      New Member
      • Oct 2012
      • 2

      #3
      Hi there, I didn't know to try that, but I just did and it worked! Thanks so much!

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        No problem, good luck with the rest of your project.

        Comment

        Working...