A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Object declarations



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old September 11th 08, 05:56 PM posted to microsoft.public.outlook.program_vba
Sierk
external usenet poster
 
Posts: 12
Default Object declarations

Got the answer. Found it in
http://blogs.msdn.com/synergist/arch...l-message.aspx
in a message posted on Saturday, August 04, 2007 5:09 PM by a Gary. Per his
suggestion I did the following:

Created a Function to retrieve the current item:

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
' anything else will result in an error, which is
' why we have the error handler above
End Select

Set objApp = Nothing
End Function
'From http://www.outlookcode.com/codedetail.aspx?id=50

Then invoked the function in my code as follows

Public Sub GetContactTitleData()
Dim oContact As Outlook.ContactItem

Set oContact = GetCurrentItem()
MsgBox oContact.Account

End Sub

I'll have to include some error trapping but I think the fundamentals are
here, and they seem to work. Thanks to all who helped, especially Ken
--
Sierk



Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CPAO: object reference not set to an instance of an object Caroline Outlook - Calandaring 2 November 29th 08 05:32 AM
Use Treeview object Boein Outlook - Using Forms 0 June 10th 08 11:51 AM
Why does the Address property of the Recipient object in the Outlook object model look funny? Omatase Outlook - General Queries 2 July 13th 07 10:09 PM
Object reference not set to an instance of an object [email protected] Outlook - General Queries 0 May 17th 07 08:40 AM
VBE Object for Outlook Dave Miller Outlook and VBA 8 January 31st 07 06:02 PM


All times are GMT +1. The time now is 08:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.