Need a Word VBA program

R

Richard

I have Word 07 running on XP.

I would like to have a Word program to change styles in a large doc. I would
like it to first check if all the words are Normal style between the "*" and
"}" in the doc, then change the words between the "*" and "}" to "Footnote
Text" style.



I would appreciate any help I can get



Richard
 
S

Shasur

Hi Richard

Here is a hint

Sub Find_Replace_Style()

Dim FindChar
Dim ReplaceRange
Dim rngStory As Range
Dim sPos As Long
Dim ePos As Long


Selection.HomeKey wdStory, wdMove
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Format = True
Selection.Find.MatchWildcards = True
Selection.Find.Execute FindText:="\*[!}]{1,}\}"
Do While Selection.Find.Found = True
sPos = Selection.Start
ePos = Selection.End
Selection.SetRange sPos + 1, ePos - 1
If Selection.Style = "Normal" Then
Selection.Style = "FootNote"
End If
Selection.MoveRight
Selection.Find.Execute FindText:="\*[!}]{1,}\}"
Loop


End Sub


I have used WildCards to find the text. If it doesn't suit, you can use
Selection.Find and Selection.Extend

Cheers
Shasur
 
R

Richard

Thanks.... I got it to work for me

Richard

Shasur said:
Hi Richard

Here is a hint

Sub Find_Replace_Style()

Dim FindChar
Dim ReplaceRange
Dim rngStory As Range
Dim sPos As Long
Dim ePos As Long


Selection.HomeKey wdStory, wdMove
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Format = True
Selection.Find.MatchWildcards = True
Selection.Find.Execute FindText:="\*[!}]{1,}\}"
Do While Selection.Find.Found = True
sPos = Selection.Start
ePos = Selection.End
Selection.SetRange sPos + 1, ePos - 1
If Selection.Style = "Normal" Then
Selection.Style = "FootNote"
End If
Selection.MoveRight
Selection.Find.Execute FindText:="\*[!}]{1,}\}"
Loop


End Sub


I have used WildCards to find the text. If it doesn't suit, you can use
Selection.Find and Selection.Extend

Cheers
Shasur
--
http://vbadud.blogspot.com


Richard said:
I have Word 07 running on XP.

I would like to have a Word program to change styles in a large doc. I
would
like it to first check if all the words are Normal style between the "*"
and
"}" in the doc, then change the words between the "*" and "}" to
"Footnote
Text" style.



I would appreciate any help I can get



Richard
 

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

Top