Outlook 2003 and getting folders with script

  • Thread starter Thread starter Tony Murnion
  • Start date Start date
T

Tony Murnion

I have a button set up on a custom contact from to add a journal entry for a
contact. It worked fine until I went to Outlook 2003 and now I get the
error because the routine is not able to get the folder name. The following
is the script that I believe is not working correctly. It still works fine
with Outlook 2002

Function GetFolder (pintFolderType, objFolder)
Dim objMyFolders
Dim i
GetFolder = False
Set objMyFolders = Item.Parent.Folders

i = 1
Do While i <= objMyFolders.Count
If objMyFolders.Item(i).DefaultItemType = pintFolderType Then
Set objFolder = objMyFolders.Item(i)
GetFolder = True
Exit Do
End If

i = i + 1
Loop

If Not GetFolder then
MsgBox gstrErrorFolder, vbCritical, gstrAppName
End If
End Function


Thanks in Advance

Tony
 
I'm not sure what the purpose of this function is. Why do you believe this
particular function is not working? What error are you seeing?
 
I inherited these functions and am trying to find the cause of the error
that pops up with 2003. I think this function is designed to get the name
of the folder for the new journal item (there are also buttons for new
contact and email that also do not work). This function gets called and the
parameter passed in the case of a new journal is "olJournalItem" through
pintFolderType variable

I beleive the script is working until this procedure and drops to the last
if statement "if Not GetFolder then" because the message box that pops up
has the error text specified earlier in another part of the script. I'm
wondering if the "Set objMyFolders = Item.Parent.Folders" line is valid. It
does not appear to be finding a match while running through the folders.


Here is more of the script:
Call CreateButton (objCommandBar, "Prospect Journal", 1990, "Create Shared
Journal", False, "cmdJournal_Click")
______________________________
Sub cmdJournal_Click()
Call ButtonClick (olJournalItem)
End Sub
_______________________________
Sub ButtonClick (pintItemType)
Dim objTargetFolder
Dim objNewItem
'Item has to be saved, otherwise linking does not work.
If Item.EntryId = "" then
If MsgBox(gstrErrorButton, vbYesNo + vbQuestion, gstrAppName) = vbYes then
Item.Save
Else
Exit Sub
End if
End If

If GetFolder (pintItemType, objTargetFolder) Then
if pintitemtype <> 2 then
'use folder from getfolder
Else
'set folder to prospects
Set objTargetFolder = Item.parent
End if
etc..................
____________________________________

Thanks

Tony
 
I'm wondering if the "Set objMyFolders = Item.Parent.Folders" line is

This statement is always valid.

The problem would seem to be that the item's parent folder has no journal
folders. I presume you're trying to add a journal item to some user-created
folder, rather than the default Journal folder?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top