View Single Post
  #5  
Old July 6th 09, 05:31 PM posted to microsoft.public.outlook.program_vba
Mats Samson
external usenet poster
 
Posts: 12
Default Switch Mail format

Ken,
I find the code confusing!
The WithEvents doesn't fit in to a Module, they seem to fit into a
ThisOutlookSession!?! If I run it from there I get compile error in the "Sub
colInsp_NewInspector(Inspector As Inspector), not matching description or
having the same name.
Furthermore the Sub oInsp.Activate() must be oInsp_Activate, right?

The best solution would be if I can attach the code to a toolbar button so
when I want to send a fax, I press the button and I get a new plain text
message.
Regards
Mats



"Ken Slovak - [MVP - Outlook]" wrote:

You will obviously need a reference to Outlook in your VBA project. Then in
a code module something like this:

' Module level code
Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents oInsp As Outlook.Inspector
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace

Dim blnFirstActivate As Boolean

Sub SetThingsUp()
Set oApp = CreateObject("Outlook.Application")
Set oNS = oApp.GetNameSpace("MAPI")
oNS.Logon "", "", False, False
Set colInsp = oApp.Inspectors
End Sub

Sub colInsp_NewInspector(Inspector As Inspector)
If (Inspector.CurrentItem.Class = olMail) Then
blnFirstActivate = False
Set oInsp = Inspector
End If
End Sub

Sub oInsp.Activate()
If (Not blnFirstActivate) Then
blnFirstActivate = True

If (oInsp.CurrentItem.BodyFormat = olFormatHTML) Then
oInsp.CurrentItem.BodyFormat = olFormatPlain
End If
End If
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mats Samson" wrote in message
...
Thanks Ken,
but I'm fairly unfamiliar with Outlook programming, usually I work with
Excel and I know there are special arguments etc that have to be set
before
Outlook cooperates with you, so..... I would appreciate if you can give me
a
code example?
Cheers
Mats



Ads