accessing outlook with late binding

J

Jim Burke in Novi

I have been using early binding to access outlook (using tools, references to
set a reference to Outlook). When I try to use late bnding I get an error
message.
Here are the statements I use to get at the appointments:

Dim objOutlook As Outlook.Application
Dim allApptItems As Outlook.Items

Set objOutlook = New Outlook.Application
Set allApptItems =
objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items

This works fine. I can loop through all appointment items. But when I change
to the following I get error message 'Could not complete the operation. One
or more parameter values are not valid.' It happens on the Set statement for
the items.

Dim objOutlook As Object
Dim allApptItems As Object

Set objOutlook = CreateObject("Outlook.Application")
Set allApptItems =
objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items

This technique (remove reference and declare variables as objects) works OK
for me when I open Excel from Access, but there must be some extra step I
need for Outlook that I'm missing. Any ideas?
 
J

Jim Burke in Novi

I found the problem. You can't access the constants (olFolderCalendar) when
using late binding. The value for olFolderCalendar is 9, so when I plugged
that in it worked fine.
 
D

David C. Holley

I discovered that the hard way as well. To get around that I ended up
declaring my own constants such as wms_olFolderCalendar so that I could
keep some semblence of sanity.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top