FolderName the folder being looked for ... i.e. "Personal Folders/Inbox\EE\cv\", ('\' & '/' are automatically corrected).
createFolders is a boolean, if true creates the folder path whereas if false, (the default) it only checks if the path is valid.
Public Function olNav2Folder(foldername As String, Optional createFolders As Boolean) As Object
Dim olApp As Object
Dim olNs As Object
Dim olfldr As Object
Dim reqdFolder As Object
Dim arrFolders() As String
Dim nestCount As Integer
On Error Resume Next
foldername = Replace(Replace(foldername, "/", "\"), "\\", "")
If Right(foldername, 1) = "\" Then foldername = Left(foldername, Len(foldername) - 1)
arrFolders() = Split(foldername, "\")
Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set reqdFolder = olNs.folders.Item(arrFolders(0))
For nestCount = 1 To UBound(arrFolders)
If Not reqdFolder Is Nothing Then
Set olfldr = reqdFolder.folders
Set reqdFolder = olfldr.Item(arrFolders(nestCount))
If reqdFolder <> olfldr.Item(arrFolders(nestCount)) Then
If createFolders Then
reqdFolder.folders.Add (arrFolders(nestCount))
Set olfldr = reqdFolder.folders
Set reqdFolder = olfldr.Item(arrFolders(nestCount))
Else
Set reqdFolder = Nothing
Exit For
End If
End If
Else
End If
Next
Set olNav2Folder = reqdFolder
Set olApp = Nothing
Set olNs = Nothing
Set olfldr = Nothing
Set reqdFolder = Nothing
End Function
Return to Module ListReturn to Module ListdosPath is the folder being looked for ... i.e. "c:\deleteme\sub1\sub 1a".
createFolders is a boolean, if true creates the folder path whereas if false, (the default) it only checks if the path is valid.Function md(dosPath As String, Optional createFolders As Boolean) ' Modified to account for UNC paths Dim fso As Object Dim fldrs() As String Dim rootdir As String Dim fldrIndex As Integer Dim arr() As String Dim elem As Integer Dim strFilePath As String md = True Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FolderExists(dosPath) Then If Left(dosPath, 2) = "\\" Then dosPath = Right(dosPath, Len(dosPath) - 2) fldrs = Split(dosPath, "\") fldrs(0) = "\\" & fldrs(0) Else fldrs = Split(dosPath, "\") End If If UBound(fldrs) = 1 Then md = False Exit Function Else strFilePath = fldrs(0) For elem = 1 To UBound(fldrs) strFilePath = strFilePath & "\" & fldrs(elem) If Not fso.FolderExists(strFilePath) Then If createFolders Then fso.CreateFolder strFilePath Else md = False Exit Function End If End If Next End If End If End Function
Return to Module Listfn is the filename including path that is being validated ... i.e. "c:\deleteme\sub1\sub 1a".
Public Function dirF(ByRef fn As String) As Boolean
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
dirF = False
If fso.FileExists(fn) Then dirF = True
End Function
Sub remoteChangeViewFilter()
Dim param As Variant
param = Application.ActiveExplorer.CommandBars.ActionControl.Parameter
MsgBox param
End Sub
Return to Module List