GetPublicFolder() function


M

Morgan

ok I'm very new to programing in Outlook. I have a custom form with 3
command buttons on it and I want to use the GetPublicFolder() function but
not sure how to call the function for each button or if it needs to be
inside the Sub for each button see code below




Public Function GetPublicFolder()

Dim colFolders
Dim objFolder
Dim arrFolders
Dim i
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders = Split(strFolderPath, "\")

Set objFolder = Application.Session.GetDefaultFolder(18)
Set objFolder = objFolder.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For i = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(i))
If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetPublicFolder = objFolder
Set colFolders = Nothing
Set objApp = Nothing
Set objFolder = Nothing
End Function


'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
'ZZ need to call public function GetPublicFolder() ZZZ
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

'Action and call for Create Contact History
Sub creathist_Click()
'need to assign projourn as default form
GetPublicFolder(Public Folders\All Public Folders\Construction\Project
Jornals\)
MsgBox "This will open Project Journals"
End Sub

'Action and call for Create Task
Sub CommandButton4_Click()
'need to assign protask as default form
GetPublicFolder(Public Folders\All Public
Folders\Construction\construction\Project Task\)
MsgBox "This will open Project Task"
End Sub

'Action and call for Create Appt
Sub CommandButton3_Click()
'need to assign proappt as default form
GetPublicFolder(Public Folders\All Public
Folders\Construction\construction\Project Appointmenst and Dates\)
MsgBox "This will open Project Appointmenst and Dates"
End Sub
 
Ad

Advertisements

S

Sue Mosher [MVP-Outlook]

The syntax for calliing any function includes doing something with the result that the function returns, usually setting a variable's value. Since this function returns an object, you must use the Set keyword. Also, the function's sole parameter -- the path to the folder -- must be a string. Since you're using string literals, you must enclose them in quotation marks, for example:

Set publicJournalFolder = GetPublicFolder("Public Folders\All Public Folders\Construction\Project Journals\")
Set newJournalItem = publicJournalFolder.Items.Add

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top