LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default repost: need help trying to automate Outlook from XL, with late binding

I'm (for the first time) developing a cross-office mini-app that includes
OL; this is also the first time I've been in an environment where different
levels of the libraries are co-existing, requiring me to use late binding.
So far, I like early binding a lot better :-/

I'm trying to get appointment information from OL using late binding. I've
used intellisense with the library referenced, and also explored (to my
limited understanding) the OL object model via OL VBA. Unfortunately, no
matter what I do, once I try to run my late binding code, it get "object
doesn't support this property or method" errors, and I haven't been able to
figure out what the heck I'm doing wrong.

So, I'm posting the relevant section of my code below, with hat in hand,
hoping someone can lend some syntax help. I appreciate any help you can
offer... if you want to be my hero, please also provide suggestions on
syntax to get the appointment subject, start date, end date, and duration as
well... I haven't even gotten that far yet...
Keith

==========================================
'for late binding:
Dim olApp As Object
Dim olNs As Object
Dim olFldr As Object
Dim olApt As Object

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set olFldr = olApp.GetFolderFromID("MAPIFolder") '<--errors out
Set olApt = olFldr.getappointmentitem("olFolderCalendar")


'for early binding
' Dim olApp As Outlook.Application
' Dim olNs As Namespace
' Dim olFldr As MAPIFolder
' Dim olApt As AppointmentItem

' Set olApp = New Outlook.Application
' Set olNs = olApp.GetNamespace("MAPI")
' Set olFldr = olNs.GetDefaultFolder(olFolderCalendar)

'***** Pull all outlook data into an array *****
For Each olApt In olFldr.Items
If InStr(1, olApt.Subject, "Vacation", vbTextCompare) 0 Then
If Year(olApt.Start) = 2005 Then
MyDur = olApt.Duration / 60
If MyDur 8 Then MyDur = 8

' UseRow = Format(olApt.Start, "mm")
eachmonth = Val(Format(olApt.Start, "mm"))
ThisDay = Val(Format(olApt.Start, "dd"))
'LastDay = Val(Format(olApt.End, "dd"))


'Gives starting row position
PasteMonthStartRow = 16 * ((eachmonth - 1) \ 3) + 17

'gives 1, 2, or 3 for the column grouping
PasteMonthStartColumn = (eachmonth Mod 3)
If PasteMonthStartColumn = 0 Then PasteMonthStartColumn = 3
'Gives the number of the actual start column
PasteMonthStartColumn = ((PasteMonthStartColumn - 1) * 7) +
1

OffsetX = (((MAdjArray(eachmonth)) + (ThisDay - 1)) \ 7) * 2
OffsetY = ((MAdjArray(eachmonth)) + (ThisDay - 1)) Mod 7

PasteMonthRow = PasteMonthStartRow + OffsetX
PasteMonthColumn = Trim(Chr((PasteMonthStartColumn +
OffsetY) + 64))

With oWrkSht
.Activate
.Range(PasteMonthColumn & PasteMonthRow).Select
Selection.Value = MyDur
Selection.AddComment (olApt.Subject)
End With

'MsgBox "Appt found:" & Chr(13) & Format(olApt.Start,
"mm/dd/yy") & Chr(13) & _
' "'" & PasteMonthColumn & "' '" & PasteMonthRow &
"'" & Chr(13) & _
' "'" & PasteMonthStartColumn & "' '" &
PasteMonthAddColumns & "'" & Chr(13) & _
' "'" & PasteMonthStartRow & "' '" &
PasteMonthAddRows & "'" & Chr(13)


'Debug.Print olApt.Subject, MyDur, Format(olApt.Start,
"mm/dd/yy")

End If
End If
Next olApt

Set olApt = Nothing
Set olFldr = Nothing
Set olNs = Nothing
Set olApp = Nothing




--
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.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Late Binding to Outlook from Excel: Outlook modifies email body Lenny Wintfeld Excel Programming 0 December 12th 04 04:03 PM
Late Binding help, Please Bud Dean Excel Programming 5 September 24th 04 04:31 AM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM
DAO Late Binding? Sharqua Excel Programming 2 January 4th 04 02:05 AM
Creating a MailItem in Outlook from Excel using Late Binding Steven Kelder Excel Programming 3 December 17th 03 05:34 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"