I have a script that extracts outlook calendar data and puts it into an Excel Spreadsheet. When I give the user the option to pick what calendar folder they want to use the code works perfect ... however I am making this a scheduled task that runs weekly and so I am trying to hardcode the calendar folder and I get an error ...
Here is the code using PickFolder...
SelectCalendarFolder:
'Allow user to select Calendar folder
Set nms = Application.GetNamespace("MAPI")
Set fld = nms.PickFolder
MsgBox nms
MsgBox fld
If fld Is Nothing Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
'Debug.Print "Default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olAppointmentItem Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
Here is the code where I have hardcoded it ...
SelectCalendarFolder:
'Allow user to select Calendar folder
Set nms = Application.GetNamespace("MAPI")
Set fld = nms.Folders("Aera wide Kaizens Test").Folders
If fld Is Nothing Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
'Debug.Print "Default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olAppointmentItem Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
Can anyone see what I am doing wrong ... thanks!!!
gwoman
Here is the code using PickFolder...
SelectCalendarFolder:
'Allow user to select Calendar folder
Set nms = Application.GetNamespace("MAPI")
Set fld = nms.PickFolder
MsgBox nms
MsgBox fld
If fld Is Nothing Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
'Debug.Print "Default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olAppointmentItem Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
Here is the code where I have hardcoded it ...
SelectCalendarFolder:
'Allow user to select Calendar folder
Set nms = Application.GetNamespace("MAPI")
Set fld = nms.Folders("Aera wide Kaizens Test").Folders
If fld Is Nothing Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
'Debug.Print "Default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olAppointmentItem Then
MsgBox "Please select a Calendar folder"
GoTo SelectCalendarFolder
End If
Can anyone see what I am doing wrong ... thanks!!!
gwoman