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