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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Outlook From Access

Status
Not open for further replies.

pjd218

Technical User
Apr 14, 2008
40
US
Using a bit of code to browse and open Outlook folders from a form in Access (2007).

Code works fine. If I press the Cancel button in the "browse for Outlook folder" window, get a runtime 91 error.

See code below:

Private Sub Command187_Click()
Dim mOutlookApp As Outlook.Application
Dim mNameSpace As Outlook.NameSpace
Set mOutlookApp = New Outlook.Application
Set mNameSpace = mOutlookApp.GetNamespace("MAPI")
mNameSpace.PickFolder.Display
Set mNameSpace = Nothing
Set mOutlookApp = Nothing
End Sub

Would like to be able to cancel out of the Outlook window opened from Access and forego the standard windows error message.
 
How are ya pjd218 . . .

[blue]PickFolder[/blue] returns a [blue]Mapi Folder Object[/blue] or [blue]Nothing[/blue] if Cancel is selected. I don't believe there's a method or property to tell wether an object is set or not.

You'll have to perform [blue]error trapping[/blue] on this one.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks Ace.

I can manipulate code just enough to really make my life miserable, so error trapping is probably out of the question, at least from my end.

Ideally, I would like to modify this piece to save the link to the folder in the database. However, since these links are primarily project specific and once a project is complete the emails are saved to PDF and the folder deleted from Outlook, having a dead link would serve little purpose, though I can always link to the PDF file and save in Access, which I can handle (saving link to table).

I guess I was looking for a statement that could run after the display code if cancel is selected to get rid of the error message but that would need to be done on the Oulook side.

Tks for the reply.

This site is great for us "rookie" programmers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top