View Single Post
  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Ed Ed is offline
external usenet poster
 
Posts: 217
Default BookMark text change

Hi swje,

You're welcome.

I suspect that I won't be able to help with the PowerPoint question. I've
never written any code for PPT.

If no-one else supplies an answer, check this thread in a couple of days and
I'll let you know whether I've found anything.

In the meantime it might be worth posting your query as a new question in
the PowerPoint NG.

Regards.

Ed


"swje" wrote:

Hi Ed,
Thanks for your help. My program can works fine now.
If it's not too much trouble,I want to ask you another question: In word, as
we said above, we can named a bookmark to save some meaningful words, and
check it's change. Is it has any object in PowerPoint can do the same things:
named a ojbect to save text, and can check it's change.

Thanks,
swje


"Ed" wrote:

Hi again,

What about something along these lines ...

In the class modue (MyObject) ...
-----------------------------------------------------------------
Public WithEvents MyApp As Word.Application

Private Sub MyApp_WindowSelectionChange(ByVal Sel As Selection)
Static BMName As String
Static BMText As String

Dim bm As Bookmark
Dim NewBMText as String

If BMName "" Then
NewBMText = ActiveDocument.Bookmarks(BMName).Range.Text
If BMText NewBMText Then
MsgBox BMName & " has changed"
End If
BMName = ""
End If

For Each bm In ActiveDocument.Bookmarks
If Selection.InRange(bm.Range) Then
BMName = bm.Name
BMText = bm.Range.Text
End If
Next
-----------------------------------------------------------------

And in a code module ...
-----------------------------------------------------------------
Dim MyWordObject As New MyObject

Sub Test()
Set MyWordObject.MyApp = Word.Application
End Sub

-----------------------------------------------------------------

It's not without its limitations as it stands - for example, if bookmarked
text is changed but the selection isn't changed afterwards, or if the
insertion point is in a bookmark range when the document opens.

Regards.

Ed

"swje" wrote:

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