Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set HTML editor as default Editor Type (VBA)

Posted on 2004-08-30
8
854 Views
Last Modified: 2013-12-16
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,

0
Comment
Question by:mgs1998
  • 4
  • 3
8 Comments
 
LVL 13

Expert Comment

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


Stefri
0
 

Author Comment

by:mgs1998
ID: 11940953
Do you have the full code? since from opening outlook from excel until set htlm editor as default.
0
 
LVL 13

Expert Comment

by:stefri
ID: 11947181
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
 
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:mgs1998
ID: 11952766
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...
0
 
LVL 13

Accepted Solution

by:
stefri earned 500 total points
ID: 11956274
Bad luck... read only property
Why do you want to set the editorType with a specific value?
You cant use bodyformat property of a mail item
See OL Help below
BodyFormat Property

Returns or sets an OlBodyFormat constant indicating the format of the body text. The body text format determines the standard used to display the text of the message. Microsoft Outlook provides three body text format options: Plain Text, Rich Text and HTML. Read/write OlBodyFormat.

OlBodyFormat can be one of these OlBodyFormat constants.
olFormatHTML
olFormatPlain
olFormatRichText
olFormatUnspecified

expression.BodyFormat

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks
All text formatting will be lost when the BodyFormat property is switched from RTF to HTML and vice-versa.

The property can not be set to olFormatUnspecified, however it will return olFormatUnspecified if the item has not yet been displayed.

Example
The following example creates a new MailItem object and sets the BodyFormat property to olFormatRichText. The Body text of the Mail item will now appear in Rich Text format.


Sub NewMail()
'Creates a new Mailitem and modifies its properties

    Dim olApp As Outlook.Application
    Dim objMail As MailItem
    Set olApp = Outlook.Application
    'Create mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       .DownloadState = olHeaderOnly
       'Set body format to Rich Text
       .BodyFormat = olFormatRichText
       .Display
    End With

End Sub

stefri
0
 

Author Comment

by:mgs1998
ID: 11956582
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.....
0
 
LVL 13

Expert Comment

by:stefri
ID: 11960956
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
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 23805160
"BodyFormat = olFormatRichText" seems not available on Outlook 2000: how can I do then to set the email editori previously?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question