Link to home
Start Free TrialLog in
Avatar of mgs1998
mgs1998

asked on

Set HTML editor as default Editor Type (VBA)

I am using a excel worksheet, I need, using VBA, to set html as the editor type for all messages that will be send. I mean as default editor type,

Avatar of stefri
stefri
Flag of France image

in your vba code, use mail.HTMLBody to set the HTML code
It has to be fully compliant with HTML standard.


Stefri
Avatar of mgs1998
mgs1998

ASKER

Do you have the full code? since from opening outlook from excel until set htlm editor as default.
open excel, open vba
add a ref to ms outlook
try this piece of code from one of my example which I had to slaughter a little to give you an idea

Public Sub createAmail()


Dim olApp As Outlook.Application
Dim theMail As Outlook.MailItem


    olExist = True
    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")

    If Err.Number <> 0 Then
        olExist = False
        Err.Clear
        On Error Resume Next
        If Not IsEmpty(olApp) Then
            Set olApp = CreateObject("Outlook.Application")
        End If
       
        If Err.Number <> 0 Then
            Err.Clear
            MsgBox "Cant start Outlook", vbCritical, "Error"
            Exit Sub
        End If
    End If

    Set myNamespace = olApp.GetNamespace("MAPI")

    Set themail = olApp.CreateItem(olMailItem)
    theBody = "<html><title>my first test</title><body><p><B>My first Test</b></p></html>
    theMail.HTMLBody = theBody

    theMail.Recipients.Add "jdoe@xxx.com"
    theMail.Display True
    'theMail.Send
    set theMail = nothing
    set myNamespace = nothing

    If olExist = False Then
        olApp.Application.Quit
        Set olApp = Nothing
    End If

End Sub
stefri
PS: it will not set HTML default editor but will create a mail using HTML format
Setting HTML as editor is from
olApp.ActiveInspector.editorType
can be one of the following value:

    Const PlainText = 1
    Const HTML = 2
    Const RTF = 3
 
Avatar of mgs1998

ASKER

Almost perfect but when I am setting HTML as default editor a message appear telling that is not possible to set that property in a read-only property. Any solution?????


Help please...
ASKER CERTIFIED SOLUTION
Avatar of stefri
stefri
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgs1998

ASKER

I have to write a macro that enable a signature, nevertheless to insert this signature I have to enable HTML editor(Signature contains picture)This macro will go to the event workbooks_open, when somebody open this excel file it will set up html editor and modify the signature.....
I am afraid you cant modify the editor type but you can create a mail using html format
fill the html body as mentionned before and force the message format  with bodyformat set to olFormatHTML
"BodyFormat = olFormatRichText" seems not available on Outlook 2000: how can I do then to set the email editori previously?