View Single Post
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
swje swje is offline
external usenet poster
 
Posts: 14
Default BookMark text change

Ed,
Thanks for your post. Your way can work the problem out.
But if there too many bookmarks defined, the efficiency will be not so good,
I want to check it in WindowSelectionChange event, it can get the select
range changed text, but can't get the original range text before change, if
there will be a WindowSelectionClick event and so on, everything will be OK.

Thanks,
swje

"Ed" wrote:

Hi swje,

If you can tell us why you want to know that and what you want to do with
the imformation someone may be able to suggest something suitable.

In the meantime, is something (very basic) like this of any use ...

A macro which you run before editing the document which saves bookmark names
and bookmarked text into a collection, and a macro which you run after the
edit which compares bookmarked text in the document with the corresponding
text that was saved by the first macro.

E.g.

In a module's Declarations section you could have something like this:

Dim BMColl as collection

and then two sub-procedures like this:

Dim BMColl As Collection

Sub Before()

Dim bm As Bookmark

Set BMColl = New Collection

For Each bm In ActiveDocument.Bookmarks
BMColl.Add bm.Range.Text, bm.Name
Next

End Sub

Sub After()
Dim bm As Bookmark

For Each bm In ActiveDocument.Bookmarks

If bm.Range.Text BMColl.Item(bm.Name) Then
MsgBox bm.Name & " has changed"
End If
Next

Set BMColl = Nothing
End Sub

Regards.

Ed
"swje" wrote:

Hi Ed,
Thanks for your post.
My question is I have made some bookmark in a document, when eidt the
document I want code to known where the changed text in a bookmark or not?
Thanks,
swje

"Ed" wrote:

Hi swje,

I don't know if this is what you want but you can turn on the display of
bookmarks.

Up to Word 2003, go to Tools Options View Show, and tick Bookmarks.

In Word 2007, go to Office Button Word Options Advanced Show document
content, and tick "Show bookmarks".

Bookmarks which don't span a range show up as a grey "I" and bookmarks which
do span a range show up as grey square brackets.

Regards.

Ed

"swje" wrote:

Hi,
when eidt a word in document, is there any way to konwn the changed word
inside a bookmark or not ?

Thanks,

swje
2007/8/20