C
Cass
I am trying to get a code for exporting data from an outlook form to
default to export a certain folder. I keep getting the Object Could
not be found error. When I try it with my personal folders it work but
when i try it with the public I can't get it to work. Is it set up
wrong for public folder selection? Please help
I get the error on " Set olTest = olFolder.Folders("Test Folder")"
Heres the code...
Sub Auto_Open()
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olTest As Outlook.MAPIFolder
Dim olColItems As Outlook.Items
Dim olItem As Object
Dim strDummy As String
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim i As Long
Application.ScreenUpdating = False
'Instantiate the MS Outlook objects.
Set olApp = Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.Folders("Public Folders")
Set olTest = olFolder.Folders("Test Folder")
If olFolder Is Nothing Then
GoTo ExitSub
ElseIf olFolder.DefaultItemType <> olContactItem Then
MsgBox "The selected folder does not contain contacts.",
vbOKOnly
GoTo ExitSub
ElseIf olFolder.Items.Count = 0 Then
MsgBox "No contacts to import.", vbOKOnly
GoTo ExitSub
End If
Set wbBook = ThisWorkbook
Set wsSheet = wbBook.Worksheets(1)
'Prepare the targeting worksheet.
With wsSheet
.Range("A1").CurrentRegion.Clear
Cells(1, 1).Value = "Utility"
Cells(1, 2).Value = "City, State & Zip"
Cells(1, 3).Value = "Main Contact"
Cells(1, 4).Value = "Main Phone Number"
Cells(1, 5).Value = "Email Address"
Cells(1, 6).Value = "Fax Number"
Cells(1, 7).Value = "Alternate Contact 1"
Cells(1, 8).Value = "Alternate Phone Number 1"......
...............
default to export a certain folder. I keep getting the Object Could
not be found error. When I try it with my personal folders it work but
when i try it with the public I can't get it to work. Is it set up
wrong for public folder selection? Please help
I get the error on " Set olTest = olFolder.Folders("Test Folder")"
Heres the code...
Sub Auto_Open()
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olTest As Outlook.MAPIFolder
Dim olColItems As Outlook.Items
Dim olItem As Object
Dim strDummy As String
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim i As Long
Application.ScreenUpdating = False
'Instantiate the MS Outlook objects.
Set olApp = Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.Folders("Public Folders")
Set olTest = olFolder.Folders("Test Folder")
If olFolder Is Nothing Then
GoTo ExitSub
ElseIf olFolder.DefaultItemType <> olContactItem Then
MsgBox "The selected folder does not contain contacts.",
vbOKOnly
GoTo ExitSub
ElseIf olFolder.Items.Count = 0 Then
MsgBox "No contacts to import.", vbOKOnly
GoTo ExitSub
End If
Set wbBook = ThisWorkbook
Set wsSheet = wbBook.Worksheets(1)
'Prepare the targeting worksheet.
With wsSheet
.Range("A1").CurrentRegion.Clear
Cells(1, 1).Value = "Utility"
Cells(1, 2).Value = "City, State & Zip"
Cells(1, 3).Value = "Main Contact"
Cells(1, 4).Value = "Main Phone Number"
Cells(1, 5).Value = "Email Address"
Cells(1, 6).Value = "Fax Number"
Cells(1, 7).Value = "Alternate Contact 1"
Cells(1, 8).Value = "Alternate Phone Number 1"......
...............