Solved

Finding the path to a calendar in outlook

Posted on 2008-10-16
13
640 Views
Last Modified: 2012-05-05
I am not able to figure out what the path to my alternate calendar is.  The name of my calendar is "DSP Class Schedule"  When I'm in it, the address box in Outlook 2003 says:  outlook:Calendar\DSP Class Schedule , but if I use "Calendar\DSP Class Schedule" as the path when trying to post an appointment to it from Access, I get the error message: "The operation failed.  An object could not be found."   My personal folders folder is actually called "Personal Folder as of 7-25-08" and it appears that calendar/dsp class schedule is a subfolder in my personal folders folder.  So for the path I used:  "Personal Folder as of 7-25-08\Calendar\DSP Class Schedule" and got the same error.  I really need to figure out the path to my alternate calendar so I can have my Access database schedule an appointment in it.  Many thanks - Emma
'Create an appointment in the Outlook Calendar - THIS CODE PUTS IT IN THE DEFAULT CALENDAR

Dim objOutlook As Outlook.Application

Dim objAppt As Outlook.AppointmentItem
 

Set objOutlook = CreateObject("Outlook.Application")
 

'''Set objAppt = objOutlook.CreateItem(olAppointmentItem)

Set objFolder = OpenMAPIFolder("Personal Folders as of 7-25-08\Calendar\DSP Class Schedule")

Set objAppt = objFolder.Items.Add
 

With objAppt

    .Start = Me!Datehearing & " " & Me!Timehearing

    .Duration = 30

    .Subject = Me!ClientContactID.Column(4) & " foreclosure hearing."

    .ReminderSet = False

    .Save

    .Close (olSave)

End With
 

Set objAppt = Nothing   'Release the AppointmentItem object variable
 

Set objOutlook = Nothing    'Release the Outlook object variable

Open in new window

0
Comment
Question by:EmmaDSP
  • 6
  • 5
  • 2
13 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 22736209
OM Gang
'Create an appointment in the Outlook Calendar - THIS CODE PUTS IT IN THE DEFAULT CALENDAR

Dim objOutlook As Outlook.Application

Dim olNS As Outlook.NameSpace

Dim olFolders As Outlook.MAPIFolder

Dim objFolder As Outlook.MAPIFolder

Dim objSubFolder As Outlook.MAPIFolder

Dim objAppt As Outlook.AppointmentItem

Dim strPST As String
 

strPST = "Personal Folders as of 7-25-08"

 

Set objOutlook = CreateObject("Outlook.Application")

Set olNS = olOutlook.GetNamespace("MAPI")

        'set object NameSpace Folders for PST file

Set olFolders = olNS.Folders(strPST)

 

'''Set objAppt = objOutlook.CreateItem(olAppointmentItem)

Set objFolder = olFolders.Folders("Calendar")

Set objSubFolder = objFolder.Folders("DSP Class Schedule")

Set objAppt = objSubFolder.Items.Add

 

With objAppt

    .Start = Me!Datehearing & " " & Me!Timehearing

    .Duration = 30

    .Subject = Me!ClientContactID.Column(4) & " foreclosure hearing."

    .ReminderSet = False

    .Save

    .Close (olSave)

End With

 

Set objAppt = Nothing   'Release the AppointmentItem object variable

Set objSubFolder = Nothing

Set objFolder = Nothing

Set olFolders = Nothing

Set olNS = Nothing

Set objOutlook = Nothing    'Release the Outlook object variable

Open in new window

0
 

Author Comment

by:EmmaDSP
ID: 22737012
When it hits this statement:  Set olNS = olOutlook.GetNamespace("MAPI")    (line 13 above) it gives me the error:  Object Required.    I have not idea if the folder name is part of the problem:  do you know how I can just rename it back to Personal Folders or Personal Folder (whatever the default is) rather than that odd folder name I gave it some time ago?  Many thanks - Emma
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22738008
Try replacing:

Set objFolder = OpenMAPIFolder("Personal Folders as of 7-25-08\Calendar\DSP Class Schedule")
with
Set objFolder = objOutlook..GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Folders("Personal Folders as of 7-25-08\Calendar\DSP Class Schedule")

Chris
'Create an appointment in the Outlook Calendar - THIS CODE PUTS IT IN THE DEFAULT CALENDAR

Dim objOutlook As Outlook.Application

Dim objAppt As Outlook.AppointmentItem

 

Set objOutlook = CreateObject("Outlook.Application")

 

'''Set objAppt = objOutlook.CreateItem(olAppointmentItem)

Set objFolder = objOutlook..GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Folders("Personal Folders as of 7-25-08\Calendar\DSP Class Schedule")

Set objAppt = objFolder.Items.Add

 

With objAppt

    .Start = Me!Datehearing & " " & Me!Timehearing

    .Duration = 30

    .Subject = Me!ClientContactID.Column(4) & " foreclosure hearing."

    .ReminderSet = False

    .Save

    .Close (olSave)

End With

 

Set objAppt = Nothing   'Release the AppointmentItem object variable

 

Set objOutlook = Nothing    'Release the Outlook object variable

Open in new window

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22738014
Apologies .. I see a double dot in the statement now ... obviously only use one dot at each position i.e.

Set objFolder = objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Folders("Personal Folders as of 7-25-08\Calendar\DSP Class Schedule")

Chris
0
 

Author Comment

by:EmmaDSP
ID: 22739216
Hi, Chris. Using your code above I'm back to the error message "The operation failed. An object could not be found."  BUT, both of you have given me some possibilities of how to specify the desired folder and perhaps I can make my original code work now.  Unfortunately, I won't be able to work on this until later today.  I'm open to any other suggestions, and I'll post here again when I've had time to work with the code some more (later today, hopefully).  Many, many thanks. - Emma
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22739284
In your original code you used objFolder, I re-used it but there is no definition of objFolder  in the snippet ... are you sure it is defined something like:

dim objFolder as outlook.mapifolder?

Chris
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:EmmaDSP
ID: 22739415
Hi, Chris.  Yes, that dim statement does exist in my code.  Thanks! - Emma
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22739533
Sorry to be pedantic but it seems to be the only thing that can justify object not found so my apologies for questioning you but are you certain that the declaration is in scope for the code snippet as supplied?

Beyond this the only other thing I can think of is "Personal Folders as of 7-25-08\Calendar\DSP Class Schedule" are you certain this ius the exact spelling and presentation of the folder in the outlook folders display?

Chris
0
 

Author Comment

by:EmmaDSP
ID: 22739597
Hi, Chris. I totally understand your question: I'd like to be able to "copy" and then "paste" the folder name, so I'm sure it's exactly the folder name, but I can't find a place where "copy" works.  I have to go to meetings now.  I'll work on this again later today (hopefully) and see if I can meet with some success.  I'll post back here with status and/or info at that time.  Thanks much! - Emma
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22739961
If you can provide a snapshot of the folderpath then that would be good otherwise in outlook, select the calendar and in the immediate window of the VBE type:

print application.ActiveExplorer.CurrentFolder.FolderPath

Hopefully that will confirm the main path leaving the active calendar name to append.

Supply th elot and see what to make of it.

Chris
0
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 22741095
<<When it hits this statement:  Set olNS = olOutlook.GetNamespace("MAPI")    (line 13 above) it gives me the error:  Object Required.    I have not idea if the folder name is part of the problem:  do you know how I can just rename it back to Personal Folders or Personal Folder (whatever the default is) rather than that odd folder name I gave it some time ago?  Many thanks - Emma >>

Sorry about that Emma, I reused some existing code I have and missed that variable name change.  Try

Set olNS = objOutlook.GetNamespace("MAPI")

OM Gang

0
 

Author Closing Comment

by:EmmaDSP
ID: 31507295
Thank you so much, OM Gang.  It worked!  I can't tell you how happy I am to finally have this matter resolved.  Thanks for your help! - Emma
0
 

Author Comment

by:EmmaDSP
ID: 22744959
Thank you, OM Gang.  That worked!  The appointment is finally appearing in my alternate (non-default) calendar.  Many thanks. - Emma
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
OneNote 2010 Outlook section grayed out 4 57
Sending mail to invalid recipient address 7 63
certificate error when opening outlook 2016 4 52
outlook 4 30
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
If you don't know how to downgrade, my instructions below should be helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now