Results 1 to 1 of 1
  1. #1
    drmsktchr is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    9

    Talking VBA for HighlightColorIndex from input in Access form to Word Bookmark

    UPDATE: Resolved this on my own, it was actually the way the bookmark in the Word document was being referenced. If I only referenced the bookmark it only copied the text, but not the format. When I changed it to Cross-Reference the bookmark, it also copied the format. Nothing like spending over a day trying to find a resolution to this.

    I am a newbie to the whole VBA world of Access and though I have learned a lot, I still feel like I don't know anything at all. I am not even sure if this can be done, but I currently have two bookmarks in a Word Document that I need to be filled in from the Access form stating either PASSED (With a bright Green Highlight) and FAILED (with a red highlight). I need the text to be highlighted and I don't need the font color to be changed.

    I have looked around google, bing, forums, but it would seem either this is not a very popular method or maybe it can't even be done. I have a form in Access asking the user to input a variety of data and then to click on Option Buttons stating whether the capability has passed or failed.

    Once the user clicks on teh submit command button, the word document is opened and all of the data from Access is inserted into the associated bookmarks in Word. At the moment, I am struggling trying to figure out how to get the highlight to pass to each and every bookmark (I have tried several different methods and nothing I do seems to work).



    Right now, I have two bookmarks that pass this value. Both bookmarks accept the text of PASSED or FAILED, but only the first bookmark highlights the word. Anyone have an idea how to make sure the highlight is carried to the additional bookmarks? Is this even a possibility with VBA?

    Here is my current code:

    Code:
    'move through the bookmarks and do the following if passed is chosen 
    If passedOption.Value = True Then   
      .ActiveDocument.Bookmarks("passOrFail").Select   
      .Selection.Range.HighlightColorIndex = wdBrightGreen   
      .Selection.Text = "PASSED"   
        'reapply the bookmark to the selections   
        .ActiveDocument.Bookmarks.Add Name:="passOrFail", Range:=Selection.Range  
    
    ElseIf failedOption.Value Then   
      .ActiveDocument.Booksmarks("passOrFail").Select   
      .Selection.Range.HighlightColorIndex = wdRed   
      .Selection.Text = "FAILED"   
        'reapply the bookmark to the selections   
        .ActiveDocument.Bookmarks.Add Name:="passOrFail", Range:=Selection.Range 
    End If
    Any help would be greatly appreciated
    Last edited by drmsktchr; 02-13-2013 at 12:18 PM. Reason: Solved on Own

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Highlight Parameter value in report
    By Hank153 in forum Reports
    Replies: 3
    Last Post: 01-14-2013, 05:54 PM
  2. Replies: 2
    Last Post: 04-19-2012, 12:43 PM
  3. Tips to make access database easy to maintain
    By alsaf in forum Programming
    Replies: 9
    Last Post: 12-11-2011, 01:51 PM
  4. scaling Word OLE object in Access Report
    By Jeff Perkins in forum Reports
    Replies: 1
    Last Post: 09-11-2011, 03:18 PM
  5. Replies: 2
    Last Post: 12-07-2010, 03:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums