LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA reference to Outlook

Hi,

I picked the code below from a very good site (can't find it again). For
those who have higher version than 9.0 this doesn't work. Is there any other
way to write to code so that it adds the reference depending on what version
you have?

If anybody know where I might have picked up the code, please let me know.

Best regards
Torbjörn

'All this code only works if Excel has a reference to the Outlook library
'the sub below ensures we do
Public Sub CheckReferences()

Dim ref As Object
Static blnRefFound As Boolean
If blnRefFound = True Then Exit Sub

'do we have a reference already? if so, exit
For Each ref In Application.VBE.ActiveVBProject.References
If ref.Name = "Outlook" Then
blnRefFound = True
Exit Sub
End If
Next ref

'no reference? add it
If blnRefFound = False Then
'if you get an error below, the Outlook library is somewhere else. Search
for msoutl9.olb on your C drive, and
'when you find it, change the pathname on the next line and try again
Application.VBE.ActiveVBProject.References.AddFrom File
"C:\Program\Microsoft Office\Office\msoutl9.olb"
End If

End Sub


 
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
custimized outlook today in outlook 2007 Hal Excel Discussion (Misc queries) 2 June 20th 07 12:59 AM
excel open in outlook if outlook is running kirk Excel Discussion (Misc queries) 0 May 24th 06 06:42 PM
How can I reference an Outlook calendar holiday from Excel? Garhart Excel Discussion (Misc queries) 0 January 5th 06 08:38 PM
Send to Outlook 2000 not Outlook Express Jimbo Excel Discussion (Misc queries) 2 January 4th 05 08:19 PM
Outlook 2003 demo back to Outlook XP Pete Carr Excel Discussion (Misc queries) 1 December 22nd 04 08:04 AM


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

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

About Us

"It's about Microsoft Excel"