Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   why does vb not recognise outlook code? (http://www.outlookbanter.com/outlook-vba/100314-why-does-vb-not-recognise.html)

ninjaneer February 21st 10 01:58 PM

why does vb not recognise outlook code?
 
Hi there

I'm still a complete amateur on outlook vba, so please bear with me.

I use Outlook 2003 (that I recieved with a student package of Office) on a
Windows 7 RC PC. I want to create a Macro that formats a mail as html. I
found some example code on the internet, but it gives errors claiming not to
recognize the objects:
"Method or data member not found" in response to
Application.ActiveInspector.CurrentItem.BodyForma t = olFormatPlain

or "User-defined type not found" in response to Dim olMail As
Outlook.MailItem

Any ideas on how I can reach my goal to create a Macro that formats a mail
as html or to address the errors?

Thank you for reading my post!

Pieka

Michael Bauer [MVP - Outlook] February 22nd 10 09:44 AM

why does vb not recognise outlook code?
 


That sounds like the code isn't running in Outlook but in another
application. There you need to add a reference on Outlook to make its object
model available: Click Tools/References, and add "Microsoft Outlook x
Library".

Also, 'Application' in VBA always refers to the Application of the host
application. For instance, if the code runs in Excel, Application refers to
the root object of Excel, not to the one of Outlook. That is you need to dim
a variable as Outlook.Application, and set it to the right object.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
http://www.vboffice.net/product.html?pub=6&lang=en


Am Sun, 21 Feb 2010 05:58:01 -0800 schrieb ninjaneer:

Hi there

I'm still a complete amateur on outlook vba, so please bear with me.

I use Outlook 2003 (that I recieved with a student package of Office) on a
Windows 7 RC PC. I want to create a Macro that formats a mail as html. I
found some example code on the internet, but it gives errors claiming not

to
recognize the objects:
"Method or data member not found" in response to
Application.ActiveInspector.CurrentItem.BodyForm at = olFormatPlain

or "User-defined type not found" in response to Dim olMail As
Outlook.MailItem

Any ideas on how I can reach my goal to create a Macro that formats a mail
as html or to address the errors?

Thank you for reading my post!

Pieka



All times are GMT +1. The time now is 03:37 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-2006 OutlookBanter.com