+ Reply to Thread
Results 1 to 11 of 11

How to Use Word as Email Editor in Excel 2007

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    83

    How to Use Word as Email Editor in Excel 2007

    Hi,

    I have a spreadsheet with a UserForm created for sending emails. However, I can only send emails in plain text.

    Does anyone know of a way how I can use Word 2007 as Email Editor in Excel 2007?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to Use Word as Email Editor in Excel 2007

    Hello nobleprince,

    I am not sure I follow your post. You state that you can only send emails in plain text. You then ask about about using Word as email editor. What are you trying to do? Do you want to change the email to Rich Text Format or HTML and resend it?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-29-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to Use Word as Email Editor in Excel 2007

    Hi Leigh,

    I have a macro spreadsheet that I'm using to send emails from Excel 2007 due to lots of records.

    Yes, I want the ability to be able to send emails in Rich Text Format and/or HTML?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to Use Word as Email Editor in Excel 2007

    See Ron de Bruin's Excel email code, you should find how to send as HTML
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    08-29-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to Use Word as Email Editor in Excel 2007

    Hi RoyUK,

    I'm not able to locate the code for the HTML from the link you've sent. Could you please give more specific pointer(s)? Or a code?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to Use Word as Email Editor in Excel 2007

    Hello noblleprince,

    Here is macro that will send a specified range in HTML format within the body of the email. If this isn't what you need, let me know and I will put something together for you that does what you need.
    'Written: September 22, 2008
    'Author:  Leith Ross
    'Summary: Send a specfied worksheet range in the body of an Outlook email
    '         in HTML format.
    
    
    Sub EmailRangeInHTML(ByVal Recipient As String, ByVal Subject As String, Optional Range_To_Send As Variant)
    
      Dim FSO As Object
      Dim HTMLcode As String
      Dim HTMLfile As Object
      Dim MyApp As Boolean
      Dim olApp As Object
      Dim Rng As Range
      Dim TempFile As String
      Dim Wks As Worksheet
    
      Const ForReading As Long = 1
      Const olMailItem = 0
      Const olFormatHTML = 2
      Const UseDefault As Long = -2
        
         If IsMissing(Range_To_Send) Then
           Set Rng = Selection
         Else
           Select Case TypeName(Range_To_Send)
             Case Is = "Range"
               Set Rng = Range_To_Send
             Case Is = "String"
               Set Rng = Evaluate(Range_To_Send)
             Case Else
               MsgBox "Your Selection is Not a Valid Range."
               GoTo CleanUp
           End Select
         End If
         
         Set Wks = Rng.Parent
         TempFile = Environ("Temp") & "\Email.htm"
         
         'Start Outlook
          Set olApp = CreateObject("Outlook.Application")
          
             'Convert the Message worksheet into HTML
              With ActiveWorkbook.PublishObjects.Add( _
                SourceType:=xlSourceRange, _
                FileName:=TempFile, _
                Sheet:=Wks.Name, _
                Source:=Rng.Address, _
                HtmlType:=xlHtmlStatic)
               .Publish (True)
              End With
           
             'Read the HTML file back as a string
              Set FSO = CreateObject("Scripting.FileSystemObject")
              
              Set HTMLfile = FSO.GetFile(TempFile).OpenAsTextStream(ForReading, UseDefault)
                HTMLcode = HTMLfile.ReadAll
              HTMLfile.Close
              
             'Clean up the HTML code
              HTMLcode = Replace(HTMLcode, "align=center x:publishsource=", _
                                 "align=left x:publishsource=")
                          
             'Compose the email and send it
              Set olEmail = olApp.CreateItem(olMailItem)
                With olEmail
                  .To = Recipient
                  .Subject = Subject
                  .BodyFormat = olFormatHTML
                  .HTMLBody = HTMLcode
                  .Send
                End With
                
    CleanUp:
      'Exit Outlook
       olApp.Quit
      'Delete the Temp File
       If Dir(TempFile) <> "" Then Kill TempFile
      'Delete the Publish Object
       With ActiveWorkbook.PublishObjects
         If .Count <> 0 Then .Item(.Count).Delete
       End With
       
      'Free memory resources
       Set olApp = Nothing
       Set olEmail = Nothing
       Set FSO = Nothing
    
    End Sub

    Example of Using the MAcro
    Sub EmailMyself()
    
     'Insert your email address in place of your_name@youremail.com
      EmailRangeInHTML "your_name@youremail.com", "Sending Range in HTML test", Worksheets("Sheet1").Range("A1:E10")
      
    End Sub

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to Use Word as Email Editor in Excel 2007

    Hi nobleprince

    Assuming this issue is related to what we've been working on, the code Ive provided will send your emails in either HTML or Rich Text (at least it does in my tests). Check your settings in Outlook (New->Options->Format). Using the same procedures we've been working on, I've sent myself emails in HTML text.

    See if this works for you.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  8. #8
    Registered User
    Join Date
    08-29-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: How to Use Word as Email Editor in Excel 2007

    Hi John,

    Yes, I have re-attached the file here. I have enabled the HTML and RTF settings in Outlook 2007, but get the following error:

    Hi Sam, 
    Test Body Text 
    {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
    In the sample file I have put the signature under "sig". This is taken from the outlook/signatures RTF file. I have only put the signature into the excel "sig" as sample for you to try (i.e. create the same signature), as I prefer using the UserForm method.

    Note that I am using an icon - twitter, in the signature which seems to be giving issues in terms of displaying in the signature, instead the above random characters appear.

    Could you please check and let me know your thoughts?

    Ash
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1