Solved

Set HTML editor as default Editor Type (VBA)

Posted on 2004-08-30
8
865 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

728 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