PDA

View Full Version : Go to One Style or Another



Jano
03-10-2006, 11:00 AM
I have a document that has to character styles in it: DeltaView Insertion and DeltaView Deletion. I want a macro that will start at the beginning of the document and go to the next DeltaView Insertion or Deletion, whichever is next.

By way of explanation, DeltaView Insertion is text that has been added; and DeltaView Deletion is text that has been deleted. So I want a user to be able to click on a button and go from one proposed edit to another; similar to Word's build in "Next" feature in Track Changes.

fumei
03-10-2006, 07:01 PM
I must point out you have a little bit of a logic flaw in your post.
I want a user to be able to click on a button and go from one proposed edit to another

This is NOT the same thing as checking for character styles.

Say you have a string of text of five words. Each word is DeltaView_Insertion. No matter what you do, if you are checking words for a style, you are going to get five hits. One for each word.

Since you did not state what you mean exactly by going from one proposed edit to another it is hard to give you help in how to do that.

Do you want this button to keep going from one to the next? You don't say.

Do you want it to just do the first one it find starting from where ever you have the Selection? You don't say.

Do you want it to find the next style (be it Insertion of Deletion) and select all the contiguous text with that style? You don't say.

Do you want it to simply go to the start of any text with that style. You don't say.

In any case, if you want to search for words - not paragraphs - then it will be something like:Dim oWord
For Each oWord In ActiveDocument.Words()
If oWord.Style = "DeltaDelete" Then
' ...whatever it is you actually want to do
End If
Next

TonyJollans
03-11-2006, 06:26 PM
If I understand correctly, then all you should need to do is a single Find for the style, after which the browser buttons (below the vertical scroll bar) will change to "Next Find" (and "Previous Find") and can be used to scroll as you ask.