BookMark text change

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Explain what exactly you are trying to do. Your question is impossible to
answer as it stands.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
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
 
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
 
Hi Mayor,
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
 
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
 
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
 
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
 
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
 
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
 
Hi swje,

I've been playing around with PPT code and made a little bit of progress but
I think it would take me quite a while before I'd be able to give any decent
coding advice.

So, I'd suggest that you ask the experts in the PPT NG, and it might be
helpful if you could tell them a few things:

The version of PowerPoint you're using.
What it is you want to do.
(Including whether what you want is for design mode or presentation mode.)
Why you want to do it - i.e. the purpose of the exercise.

Hope they can help.

Regards.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top