Hello, There are Visual Basic for Applications (VBA) and Visual Basic Script examples which I would like to use as-is in perl. In the code below, the VBA subroutine FooCreateFolders() calls the VBA function GetFolderVBA(). The point is that although I plan to redo the VBA subroutine FooCreateFolders() in perl using "use Win32::OLE;", I would like to use Sue Mosher's VBA "Public Function GetFolderVBA(strFolderPath As String) As MAPIFolder" as-is .
Is this possible, or do I have to re-write GetFolderVBA in perl using Win32::OLE also? Thanks, --Suresh Sub FooCreateFolders() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myNotesFolder As Outlook.MAPIFolder Dim myContactFolder As Outlook.MAPIFolder Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myFolder = myNamespace.GetDefaultFolder(olFolderTasks) On Error GoTo ErrorHandler Set myOwnFolder = GetFolderVBA("Mailbox - Govindachar, Suresh\mm") Set myFooeyBooeyFolder = myOwnFolder.Folders.Add("Fooey") Set myOwnFolder = GetFolderVBA("Suresh's Personal Folders\p\aa") Set myFooeyBooeyFolder = myOwnFolder.Folders.Add("Booey") Exit Sub ErrorHandler: MsgBox "Error creating the folder. The folder may already exist." Resume Next End Sub Public Function GetFolderVBA(strFolderPath As String) As MAPIFolder ' folder path needs to be something like ' "Public Folders\All Public Folders\Company\Sales" Dim objApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim colFolders As Outlook.Folders Dim objFolder As Outlook.MAPIFolder Dim arrFolders() As String Dim i As Long On Error Resume Next strFolderPath = Replace(strFolderPath, "/", "\") arrFolders() = Split(strFolderPath, "\") Set objApp = CreateObject("Outlook.Application") Set objNS = objApp.GetNamespace("MAPI") Set objFolder = objNS.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 GetFolderVBA = objFolder Set colFolders = Nothing Set objNS = Nothing Set objApp = Nothing End Function Function GetFolderScript(FolderPath) ' folder path needs to be something like ' "Public Folders\All Public Folders\Company\Sales" Dim aFolders Dim fldr Dim i Dim objNS On Error Resume Next strFolderPath = Replace(FolderPath, "/", "\") aFolders = Split(FolderPath, "\") 'get the Outlook objects ' use intrinsic Application object in form script Set objNS = Application.GetNamespace("MAPI") 'set the root folder Set fldr = objNS.Folders(aFolders(0)) 'loop through the array to get the subfolder 'loop is skipped when there is only one element in the array For i = 1 To UBound(aFolders) Set fldr = fldr.Folders(aFolders(i)) 'check for errors If Err <> 0 Then Exit Function Next Set GetFolderScript = fldr ' dereference objects Set objNS = Nothing End Function _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs