Solved

Set HTML editor as default Editor Type (VBA)

Posted on 2004-08-30
8
863 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
[X]
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
  • 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
Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook for mac 2011 21 54
OUTLOOK 2016 receive time interval 8 72
Migrating emails from desktop Outlook to Exchange online 3 50
Move a email in Outlook 2016 5 61
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

737 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