Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
a_nokes
 
Posts: n/a
Default search and replace with a numbered reference

I need to do a serarch and replace through a word file, containing deltaview
delete style.

Is there a way I can do a search for these marks and replace them with a
reference code with incrementing numbers for each time the search comes up?

I would then need to call up these references, when needed.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default search and replace with a numbered reference

You may be able to adapt this to your needs:

Sub FRWithSequentialNumber()
'Finds a specified text string and replaces with a sequential number
Dim findText As String
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
findText = InputBox("Enter text to find")
With myRange.Find
.Text = findText
.MatchWholeWord = True
While .Execute
myRange.Text = Format(startNum, "000")
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
a_nokes
 
Posts: n/a
Default search and replace with a numbered reference

Thanks for the quick answer.

I tried pasting this into a macro but could not get it to work.
Sub - funtion was not defined.



"a_nokes" wrote:

I need to do a serarch and replace through a word file, containing deltaview
delete style.

Is there a way I can do a search for these marks and replace them with a
reference code with incrementing numbers for each time the search comes up?

I would then need to call up these references, when needed.

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default search and replace with a numbered reference

Well it works for me.

However, if I understand correctly you want to number sequentially
everytime a defined paragraphs style is used. This example looks for
an marks "Body Text" style. Perhaps you can adapt it to your specific
need:

Sub FRWithSequentialNumber()
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
With myRange.Find
.Style = "Body Text"
While .Execute
myRange.MoveEnd wdCharacter, -1
myRange.InsertAfter " " & Format(startNum, "000")
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
If myRange.End = ActiveDocument.Range.End - 1 Then Exit Sub
Wend
End With
End Sub

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
a_nokes
 
Posts: n/a
Default search and replace with a numbered reference

Thanks Greg for the quick answer again.

Still having trouble with getting the macro to work (dont know much about
making it)!

On the search, could I search for a style (i.e. deltaview deletion)?

And replace it with a reference (i.e. dtx1, dtx2 etc.) for the next one
and so on?




"Greg Maxey" wrote:

Well it works for me.

However, if I understand correctly you want to number sequentially
everytime a defined paragraphs style is used. This example looks for
an marks "Body Text" style. Perhaps you can adapt it to your specific
need:

Sub FRWithSequentialNumber()
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
With myRange.Find
.Style = "Body Text"
While .Execute
myRange.MoveEnd wdCharacter, -1
myRange.InsertAfter " " & Format(startNum, "000")
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
If myRange.End = ActiveDocument.Range.End - 1 Then Exit Sub
Wend
End With
End Sub




  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default search and replace with a numbered reference

Have you puthttp://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm the
macro in your document or template project? See:
Have you puthttp://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

If you have a defined style named "deltaview deletion" and you change
this line:
..Style = "Body Text"
to
..Style = "deltaview deletion" then it will "append" a sequential number
to the tail end of each bit of text formatted with the deltaview
deletion style.

If you wanted the existing deltaview deletion text replaced with the
number you could use something like:

Sub FRWithSequentialNumber()
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
With myRange.Find
.Style = "deltaview deletion"
While .Execute
myRange.MoveEnd wdCharacter, -1
myRange.Text = "dtx" & startNum
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
If myRange.End = ActiveDocument.Range.End - 1 Then Exit Sub
Wend
End With
End Sub

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
a_nokes
 
Posts: n/a
Default search and replace with a numbered reference

Thanks Greg for the information, I now have got it to work (sort of).

Is there a way that the search can see the style and put a reference code
(ie dtx#) in for the whole word, sentence, paragraph (ie multi characters,
single characters, formats and including tables?), as it appears throughout
the document.

I would then want to call this reference up to see what was inside (how?).

IS IT POSSIBLE.

Thanks for any help!



"Greg Maxey" wrote:

Well it works for me.

However, if I understand correctly you want to number sequentially
everytime a defined paragraphs style is used. This example looks for
an marks "Body Text" style. Perhaps you can adapt it to your specific
need:

Sub FRWithSequentialNumber()
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
With myRange.Find
.Style = "Body Text"
While .Execute
myRange.MoveEnd wdCharacter, -1
myRange.InsertAfter " " & Format(startNum, "000")
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
If myRange.End = ActiveDocument.Range.End - 1 Then Exit Sub
Wend
End With
End Sub


  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey
 
Posts: n/a
Default search and replace with a numbered reference

A,

If you are using a character style (vice paragraph style) to format
individual bits of text within a larger paragraph, then you might use
this to mark each bit of text,

Sub FRWithSequentialNumber()
Dim startNum
Dim myRange As Range
Set myRange = ActiveDocument.Range
startNum = InputBox("Start sequential numbers at:")
With myRange.Find
.Style = "TestCharSty" 'Replace with your style name.
While .Execute
myRange.Collapse wdCollapseEnd
myRange.Text = " dtx" & startNum
startNum = startNum + 1
myRange.Collapse Direction:=wdCollapseEnd
If myRange.End = ActiveDocument.Range.End - 1 Then Exit Sub
Wend
End With
End Sub

I don't really understand what it is that you are trying to do.

  #9   Report Post  
Posted to microsoft.public.word.docmanagement
a_nokes
 
Posts: n/a
Default search and replace with a numbered reference

I need to take a word file into our system (3B2), when taking word files with
deltaview deletion styles, the text comes in without showing any marks. This
means that we have to delete the style in word or look for the deleted text
on our system.

I am hoping that I can capture the deltaview deletion text in word and
making it easier to import into 3B2. In 3B2 strikethrough text is shown as
dtx1, dtx2 etc., you can show/hide the deleted text on the page.

I am hoping that anyone can help me achieve this.

"a_nokes" wrote:

I need to do a serarch and replace through a word file, containing deltaview
delete style.

Is there a way I can do a search for these marks and replace them with a
reference code with incrementing numbers for each time the search comes up?

I would then need to call up these references, when needed.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting into a search and replace Ben K. Bullock New Users 6 March 6th 06 05:50 AM
Search and Replace not working if I select a Format for Heading St Sherrie Deen Microsoft Word Help 0 April 27th 05 08:53 PM
Search and replace problem Jan Kronsell New Users 7 March 30th 05 09:57 AM
search and replace symbol characters Patricia G. Kurz Microsoft Word Help 1 December 29th 04 03:11 AM
search and replace symbols pattyjo Microsoft Word Help 2 December 29th 04 03:10 AM


All times are GMT +1. The time now is 06:53 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"