+ Reply to Thread
Results 1 to 6 of 6

RangetoHTML function changes formatting of everything after it

  1. #1
    Registered User
    Join Date
    01-11-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    7

    RangetoHTML function changes formatting of everything after it

    Hello all, I am on Excel 2010 VBA. I am using the Ron De Bruin RangetoHTML function to copy and paste sections of a spreadsheet to different email addresses, using an email template that I have created with placeholder text for where the RangetoHTML contents should go. I only needed the RangetoHTML for a certain section of the email body since the rest of the email will be the same for everyone else.

    Everything seems to work fine but instead of the replace function just replacing the placeholder text with the range that is copied from the spreadsheet, everything below the range in the email text is now formatted differently even though everything before the pasted range looks correct. Does anyone know how this could be fixed, if at all? The entire code I used is below.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: RangetoHTML function changes formatting of everything after it

    What happens if you do the insertion of the HTML range last? Switching the order of these two line to this:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-11-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    7

    Re: RangetoHTML function changes formatting of everything after it

    Quote Originally Posted by Bernie Deitrick View Post
    What happens if you do the insertion of the HTML range last? Switching the order of these two line to this:

    Please Login or Register  to view this content.
    It does appear to make the same mistake. Also, I think I should have mentioned that the code seems to keep the color and size of the text, but changes the font to Times New Roman which is not what it should be. And also I said everything after the RangetoHTML changed font but I meant everything after it but before the signature (which does still have the correct formatting for some reason).

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: RangetoHTML function changes formatting of everything after it

    How do you want the body of the email after the HTML section to be formatted?

    Does it make any difference if you add opening and closing HTML body tags either side of RangetoHTML(rng) here?
    Please Login or Register  to view this content.
    Note, I tried posting the tags I mentioned but apparently I broke some sort of security protocol or something in trying to do so.

    Anyway, here is a link.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    01-11-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    7

    Re: RangetoHTML function changes formatting of everything after it

    Quote Originally Posted by Norie View Post
    How do you want the body of the email after the HTML section to be formatted?

    Does it make any difference if you add opening and closing HTML body tags either side of RangetoHTML(rng) here?
    Please Login or Register  to view this content.
    Note, I tried posting the tags I mentioned but apparently I broke some sort of security protocol or something in trying to do so.

    Anyway, here is a link.
    The text after the RangetoHTML and before the signaturshould be Calibri font, size 11, and RGB 31,73,125. So you mean use the literal tags that have the letters html inside or some other combination of html tags (like body or something else)? By the way I am writing it out in words to avoid the same error you mentioned by including HTML tags.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: RangetoHTML function changes formatting of everything after it

    If you want to apply specific formatting to a section of the email body when you are using HTMLBody you might want to look at using the HTML tags that requires.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Preserve Hyperlinks Using rangetohtml excel to outlook vba code
    By Pang_george in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2017, 09:56 PM
  2. Format body in RangetoHTML
    By Rui Farinha in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2016, 01:22 PM
  3. Return to orignail view after rangetohtml coding.
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2013, 09:35 AM
  4. RangetoHTML
    By bigpappi23 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-23-2013, 04:10 AM
  5. RangetoHTML issue, Excel 2003
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-15-2011, 04:51 AM
  6. Setting RANGE for RangeToHTML
    By kmkelley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2011, 11:08 AM
  7. Sending Worksheet in body of email: RangetoHTML
    By mojo249 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2010, 11:23 AM

Tags for this Thread

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