Home All Groups Group Topic Archive Search About

Late binding to Outlook via VBA

Author
16 Dec 2004 9:48 PM
KR

I apologize if this is a repeat post- I posted this question earlier today
but never saw it show up on the server.

I am taking an Excel XP workbook that originally was set up with early
binding to Outlook, and trying to convert it to late binding. I'm having
some trouble getting it to work, so I'm hoping someone here can point
out the appropriate Outlook code.

When using late binding, I'm having trouble converting the namespaces (if
that means what I think it means); As this is partly re-using the code
from intellisense (with early binding/ references on), I'm not sure how to
identify by myself what should go in the quotes after each statement. Any
advice would be greatly appreciated.

'for late binding:
Dim olApp As Object
Dim olNs As Object
Dim olFldr As Object
Dim olApt As Object
'do I need to dim the following to access them via late binding?
     'Dim olApt_Subject as Object
     'Dim olApt_Start as Object
     'Dim olApt_Duration as Object

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set olFldr = olNs.MAPIFolder '<---- it stops here,
                                                'error 438 unsupported
                                                'property or method
Set olApt = olFldr.AppointmentItem
etc.

My goal is to be able to cycle through all appointments and identify the
ones with "Vacation" in the subject line (using olApt.Subject), then I grab
the olApt.Start and olApt.Duration. I'm still not sure if I can access these
last
three on the fly, or if I need to Dim them as objects as well?

Many thanks,
Keith


--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.

Author
16 Dec 2004 10:24 PM
Sue Mosher [MVP-Outlook]
Why don't you add a reference and Dim the objects properly so you can take
advantage of Intellisense while you're writing the code?

You can also check the object browser in Outlook VBA: Press ALt+F11 to open
the VBA environment in Outlook, then press F2. Switch from <All Libraries>
to Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.

Take a look at Namespace.GetDefaultFolder and MAPIFolder.Items
--
Sue Mosher, Outlook MVP
Author of
     Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx


Show quoteHide quote
"KR" <nospam@nospam.com> wrote in message
news:%23KQ45j74EHA.1392@tk2msftngp13.phx.gbl...
>I apologize if this is a repeat post- I posted this question earlier today
> but never saw it show up on the server.
>
> I am taking an Excel XP workbook that originally was set up with early
> binding to Outlook, and trying to convert it to late binding. I'm having
> some trouble getting it to work, so I'm hoping someone here can point
> out the appropriate Outlook code.
>
> When using late binding, I'm having trouble converting the namespaces (if
> that means what I think it means); As this is partly re-using the code
> from intellisense (with early binding/ references on), I'm not sure how to
> identify by myself what should go in the quotes after each statement. Any
> advice would be greatly appreciated.
>
> 'for late binding:
> Dim olApp As Object
> Dim olNs As Object
> Dim olFldr As Object
> Dim olApt As Object
> 'do I need to dim the following to access them via late binding?
>     'Dim olApt_Subject as Object
>     'Dim olApt_Start as Object
>     'Dim olApt_Duration as Object
>
> Set olApp = CreateObject("Outlook.Application")
> Set olNs = olApp.GetNamespace("MAPI")
> Set olFldr = olNs.MAPIFolder '<---- it stops here,
>                                                'error 438 unsupported
>                                                'property or method
> Set olApt = olFldr.AppointmentItem
> etc.
>
> My goal is to be able to cycle through all appointments and identify the
> ones with "Vacation" in the subject line (using olApt.Subject), then I
> grab
> the olApt.Start and olApt.Duration. I'm still not sure if I can access
> these
> last
> three on the fly, or if I need to Dim them as objects as well?
>
> Many thanks,
> Keith
>
>
> --
> The enclosed questions or comments are entirely mine and don't represent
> the
> thoughts, views, or policy of my employer. Any errors or omissions are my
> own.
>
>

Bookmark and Share