Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Referring to folders (Outlook 2000)

    Hi

    I'm trying my first Outlook macro, and am having difficulty getting started. I want a macro that trolls through all the subfolders under Inbox and resets the AutoArchive period ("Clean out items older than"). But I can't even work out what the folders collection is called. I've found all sorts of mystifying examples referring to MAPI and Namespace, but haven't been able to work out what it's all about.

    Could some tell me how to write the equivalent of this:
    <pre> For each MyFolder in <folderCollection>
    Next MyFolder
    </pre>


    Thanks for your help
    Dale

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

    Re: Referring to folders (Outlook 2000)

    The Outlook object model is rather exotic and extremely limited. The AutoArchive settings are not exposed. You need CDO (Collaboration Data Objects) for that - set a reference in Tools | References... to Microsoft CDO ... Library (... is 1.21 on my Office XP system, it might be different for you). You can find lots of documentation about the nooks and crannies of CDO on CDOLive. In particular, see Tips and Tricks (search the page for AutoArchive) and Property Tags and Types. Not for the timid!

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

    Re: Referring to folders (Outlook 2000)

    Oh, and here is standard Outlook VBA code to loop through the subfolders of Inbox. You refer to folders through the NameSpace object. There is only one, of type MAPI, but you must explicitly set it each time. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15> Folders in Outlook are MAPIFolders.

    Dim nsp As NameSpace
    Dim fldParent As MAPIFolder
    Dim fldChild As MAPIFolder

    Set nsp = GetNamespace("MAPI")
    Set fldParent = nsp.GetDefaultFolder(olFolderInbox)

    For Each fldChild In fldParent.Folders
    Debug.Print fldChild.Name
    Next fldChild

    Set fldChild = Nothing
    Set fldParent = Nothing
    Set nsp = Nothing

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Referring to folders (Outlook 2000)

    You can find some more code samples on the Outlook board; I think JohnBF posted something fairly comprehensive, and I know i've posted a few snippets on this. Using MAPIFolder as a keyword might help narrow down the results.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Referring to folders (Outlook 2000)

    Thanks. That'll get me started.

    However, now that I try running an Outlook macro, I find that my security setting is "High". I guess it's off-subject, but is there any problem with changing the setting to "Low"? (I have XP Home, Norton Personal Firewall, Norton Utilities, and auto-update of Symantec virus signatures. AutoProtect is on and Norton AntiVirus is set up to scan incoming mail.)

    Dale

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

    Re: Referring to folders (Outlook 2000)

    Don't set macro security to Low. Medium is the recommended setting. High, as you found, is too restrictive, and even with all the protection you have, Low is still risky.

Posting Permissions

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