+ Reply to Thread
Results 1 to 4 of 4

Highlights in Word are not saved

  1. #1
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Highlights in Word are not saved

    Hello -

    I have a macro that is working fine but doesn't seem to save highlights that are applied to a Word Document.
    The macro works like this:
    if a particular string is inputted in Column B, take the value in Column A and find
    the string in a Word Document. Highlight the string with a particular color.

    The macro works (using .hithighlights) but when i go to save the Word document, the highlights disappear.

    Should I try another method? Save the document as something else?

    Please tell me if I need to move this to another forum etc.

    Thanks !

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlights in Word are not saved

    It would be really, really, helpful if you actually posted the code you're using; without it, no one can do more than guess what the issue might be...
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174
    Quote Originally Posted by macropod View Post
    It would be really, really, helpful if you actually posted the code you're using; without it, no one can do more than guess what the issue might be...
    Hello -

    Below is the code I am using. The macro is sufficient
    for what I need - the issue is when I do a manual save
    and reopen the file the highlights are gone.
    CODE
    Dim worddoc As Word.Document
    Dim wrng As Word.Range
    Dim erng As Range
    Set erng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    Workbooks("test.xlsm").Activate
    Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Copy
    Set worddoc = ActiveDocument
    worddoc.Paragraphs(2).Range.PasteSpecial Link:=False, DataType:=wdPasteText
    worddoc.Paragraphs.SpaceAfter = 0
    Workbooks("test.xlsm").Activate
    For Each a In Sheets("Sheet1").Range("B1:B3")
    If a.Value = "yes" Then
    Set wrng = worddoc.Range
    With wrng.Find
    .HitHighlight (a.Offset(0, -1).Value), wdColorLightGreen
    End With
    ElseIf a.Value = "no" Then
    Set wrng = worddoc.Range
    With wrng.Find
    .HitHighlight (a.Offset(0, -1).Value), wdColorRed
    End With
    Else
    End If

    Next a
    /CODE

    Thank you !

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlights in Word are not saved

    Try:
    Please Login or Register  to view this content.
    PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.

+ 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. Word files being overwritten when saved from excel.
    By DouglasWicker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2018, 05:13 AM
  2. [SOLVED] Macro Inserts row above the word Type and Highlights is taking too long to run.
    By TAMMY32 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2016, 12:24 PM
  3. Creating a Word Document with a submission form that is saved as a PDF
    By avidcat in forum Word Formatting & General
    Replies: 1
    Last Post: 10-13-2012, 07:19 AM
  4. Excel sheet Saved as word doc using cell value
    By Oreg in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-24-2006, 02:33 AM
  5. [SOLVED] why does saved doc get deleted word by word
    By sngtaprsd in forum Excel General
    Replies: 2
    Last Post: 08-20-2006, 12:30 PM
  6. [SOLVED] Excel document was saved to word in error how do I get it back
    By Janice in forum Excel General
    Replies: 1
    Last Post: 05-29-2006, 10:50 AM
  7. [SOLVED] Excel and Word will not open saved files
    By Flannagan in forum Excel General
    Replies: 2
    Last Post: 04-26-2006, 04:30 AM

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