Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Thanked 1 Time in 1 Post

    newbie (nottobe) ol obj model help (2000sp3)

    Having just moved halfway round the world, I've been hit by the timezone gotcha, and want to move all my recurring appointments (mainly anniversaries) back to the correct day. I tried to right some code for this, but got stuck at stage 1 - understanding the outlook object model so I could loop through all the appointments. I've got as far as For Each olAppointment in olFolder.items, but then get told that's an invalid qualifier. I haven't declared any of these as variables, and couldn't find a "folder" object type to declare a variable as a folder. Have not found online help very helpful in this regard.

    Would appreciate a minute of guru time to point me in right direction.


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: newbie (nottobe) ol obj model help (2000sp3)

    I haven't actually tested this code - I don't want to move my appointments <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15> - but it might look like this:

    Sub Test()
    Dim nsp As NameSpace
    Dim fld As MAPIFolder
    Dim itm As AppointmentItem

    On Error GoTo ErrHandler

    Set nsp = GetNamespace("MAPI")
    Set fld = nsp.GetDefaultFolder(olFolderCalendar)
    For Each itm In fld.Items
    itm.Start = DateAdd("h", 1, itm.Start)
    itm.End = DateAdd("h", 1, itm.End)
    Next itm

    Set itm = Nothing
    Set fld = Nothing
    Set nsp = Nothing
    Exit Sub

    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    Outlook doesn't have a Folder object, but a MAPIFolder object. Folders start from the NameSpace object, and there is only one valid NameSpace object: MAPI.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Salt Lake City, Utah, USA
    Thanked 6 Times in 6 Posts

    Re: newbie (nottobe) ol obj model help (2000sp3)

    Each folder is a 'MAPIFolder' Object. I usually reference the Items by looping through the Items collection, such as this:

    Private Sub GetAllCalendarStuff()
    Dim fldrCal As MAPIFolder
    Dim lngC As Long

    Set fldrCal = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox)

    With fldrCal
    For lngC = 1 To .Items.Count
    With .Items(lngC)
    -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