Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Calendar from Access 2

Status
Not open for further replies.

LeanneGodney

Technical User
Mar 7, 2002
175
GB
hi there, I'm battling to figure out how I can have a button in an Access form that will open up the calendar of hte current person. I know how to set permissions, and I know how to get the users name, but I just can't figure out how to open someone elses calendar from VBA.

Any ideas? I don't want to link, and have a text calendar... I want to open the original calendar like you would from Outlook (File -> Open -> Other Users Folder.

Thanks,
Leane
 
You will need to go to your code window and in Tools|References select Microsoft Outlook Object Library

Then in a procedure put the following

Dim MyApp As Outlook.Application
Dim MyNS As Outlook.NameSpace
Dim MyFolder As Outlook.MAPIFolder
Dim MyRecipient As Outlook.Recipient
Set MyApp = New Outlook.Application
Set MyNS = MyApp.GetNamespace("MAPI")

Set MyRecipient = MyNS.GetRecipientFromID("theperson")

Set MyFolder = MyNS.GetSharedDefaultFolder(MyRecipient, olFolderCalendar)

MyFolder.GetExplorer (2)
MyFolder.Display


At whatever event closes the process make sure you have the following:


Set MyFolder = Nothing
Set MyRecipient = Nothing
Set MyNS = Nothing
Set MyApp = Nothing


JHall
 
Hi JHall,

Thanks for that. I'm getting an error "could not open the item. Try again.... when you said:

Set MyRecipient = MyNS.GetRecipientFromID("theperson")

Is "theperson" the persons Login name for windows, or their mailbox account for the exchange server? Neither of these work when I try to open this persons calendar.

Any ideas?

Thanks for your time
 
I'm sorry, I did that wrong. You need to have this

Set MyApp = New Outlook.Application
Set MyNS = MyApp.GetNamespace("MAPI")
Set MyRecipient = MyNS.CreateRecipient("jhall")
MyRecipient.Resolve
If MyRecipient.Resolved Then
Set MyFolder = MyNS.GetSharedDefaultFolder(MyRecipient, olFolderCalendar)

MyFolder.GetExplorer (2)
MyFolder.Display
End If


Also when you're done, before you set your objects = Nothing,
you need to invoke MyApp.Quit otherwise an instance of outlook will stay running.

Let me know if you need anything else
JHall
 
No problem nice lady. Check out the help files in Outlook under the contents tab, Advanced Customization|Microsoft Outlook Visual Basic Reference

I like to use the first entry Microsoft Outlook Objects
from there you can drill down into all the collections and objects, exploring their properties and methods.

Best of luck to you. JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top