Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Utah, USA
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook macro (Office 2007)

    Looking for a macro that will create an appointment in Outlook. The macro will ask for the date, duration of the appointment, and start time.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook macro (Office 2007)

    I don't mean to be rude, but why do you need a macro? It will take as long enter the fields in a macro dialog as to use the standard double click the Calendar and enter the same values. (And an Appointment usually also takes a Subject.) Is this part of some other process you are calling from another Application, or from some point in Outlook outside the Calendar view?
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Utah, USA
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook macro (Office 2007)

    Not rude. I'm just lazy. I have several appointments I do quite regularly and would like to automate them. I can already create an appointment with the subject and location and duration.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook macro (Office 2007)

    Here is such a macro. It also asks for a subject. You can add more bells and whistles as desired.

    Sub CreateAppointment()
    Dim dtmDate As Date
    Dim dtmTime As Date
    Dim dtmDuration As Date
    Dim strSubject As String
    Dim objAppt As AppointmentItem
    On Error GoTo ErrHandler
    Set objAppt = Application.CreateItem(olAppointmentItem)
    dtmDate = CDate(InputBox("Enter the date", , Date))
    dtmTime = CDate(InputBox("Enter the starting time", , Time))
    dtmDuration = CDate(InputBox("Enter the duration", , #1:00:00 AM#))
    strSubject = InputBox("Enter the subject")
    With objAppt
    .Start = dtmDate + dtmTime
    .End = dtmDate + dtmTime + dtmDuration
    .Subject = strSubject
    .Save
    End With

    ExitHandler:
    Set objAppt = Nothing
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook macro (Office 2007)

    I can understand lazy. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Hans, who is much more polite than I, has given you a very nice solution. If you want to be lazier, you could hard code your most frequent subjects and locations and then when the appointment pops, edit them to the specific item (just don't confuse them). Using Hans' code:

    strSubject = InputBox("Enter the subject") ' delete this line
    With objAppt
    .Start = dtmDate + dtmTime
    .End = dtmDate + dtmTime + dtmDuration
    .Subject = "Boss, Lunch, Drinking, Football, Romance"
    .Location= "His office, Pub, Bar, Stadium, Girlfriends house"
    .Save
    .Display ' pops the appointment for editing
    End With
    -John ... I float in liquid gardens
    UTC -7ąDS

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook macro (Office 2007)

    You'd have to edit the subject and location carefully to avoid embarrassment (or worse)! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook macro (Office 2007)

    I was having a little fun. Maybe I should have included both girlfriend and wife. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Utah, USA
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook macro (Office 2007)

    Thank you both very much. I hope I did not offend, I apologize if I did.
    Dan

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook macro (Office 2007)

    No need to apologize, you didn't offend us at all.

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook macro (Office 2007)

    Not at all, your request was fine. I was being obstructive.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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