Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set Outlook object references 1

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Many of the Outlook97 help items display something like the following code. I believe the Dim statements for them would be as follows, except what do you use for the Outlook Application itself? Should I just use the generic Object?

Dim myOLApp As ???
Dim myItem As MailItem
DIm myAttachments As Attachments

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\My Documents\" & _
myAttachments.Item(1).DisplayName

Thanks in advance for any help you can give me and have a great day!
 
Hi
Never done this before but I would try declaring it as "application".

And I'll try to have a great day, thanks!
;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
You could either use
Code:
Outlook.Application
or
Code:
Object[/code
The first has the advantage of showing you the list of Properties & methods that apply the Outlook Application object. the second is more generic

NB: if you're programming in any other app than Outlook plz remmeber to set a reference to the outlook object library - if you don't the Outlook.Application object won't be available

Oh, and if you don't want threads of outlook running all over always release the objects at the end of your code:
[code]Set myOLApp = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
(-:
Cheers
Nikki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top