![]() |
GetPublicFolder() function
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 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZ need to call public function GetPublicFolder() ZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ '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 |
GetPublicFolder() function
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 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Morgan" wrote in message ... 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 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZ need to call public function GetPublicFolder() ZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ZZZZZ '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 |
All times are GMT +1. The time now is 09:15 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com