[AccessD] MS Word Highlight Problem

Max Wanadoo max.wanadoo at gmail.com
Fri Mar 12 06:51:33 CST 2010


Robert,

This works on my Word doc

Sub MYBOOK()
    Dim MYbookmark As Bookmark
    For Each MYbookmark In ActiveDocument.Bookmarks
        ' If Left(myBookmark.Name, Len(mstrBidName)) = "BidName" Then
        MYbookmark.Range.HighlightColorIndex = wdDarkYellow
        ' End If
    Next MYbookmark
End Sub

I commented  out the IF bit.

Max

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robert
Sent: Friday, March 12, 2010 12:25 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] MS Word Highlight Problem

Hey Max,
  Thanks for the suggestion. However the problem, which I should have been
more clear earlier, is not that the bookmark doesn't get found, the problem
is this:

Even though the myBookmark.Range.HighlightColorIndex property gets set to
wdDarkYellow it still does not get highlighted.

myBookmark.Range.HighlightColorIndex = 0 Before AND after I set it to
wdDarkYellow (14), and I can't figure out why....

WBR
Robert


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Thursday, March 11, 2010 7:38 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] MS Word Highlight Problem

Robert,

I would change the len(mstrbidname)  bit  to  constant 7.

You know how long "Bidname" is but you don't  know how long len(mstrbidname)
is.

So it would read:

If Left(myBookmark.Name, 7) = "BidName" Then
  myBookmark.Range.HighlightColorIndex = wdDarkYellow End If

Max
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robert
Sent: Thursday, March 11, 2010 11:05 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] MS Word Highlight Problem

Could anyone give me some clues as to why this code does not work? Trying to
highlight a text string contained in a bookmark. No errors are thrown,
simply doesn't work?


            For Each myBookmark In objword.ActiveDocument.Bookmarks
              If Left(myBookmark.Name, Len(mstrBidName)) = "BidName" Then
                 myBookmark.Range.HighlightColorIndex = wdDarkYellow
              End If
            Next myBookmark

WBR
Robert


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list