O
ondy
Hi all,
I'm having what is a problem trying to create a macro that uses tabs, which
will later be used in converting text to a table.
It's fine when I use search and replace to place tabs, using ^t, when I know
exactly what the search will find.
But when I search for a piece of code, followed by a digit, I can't use S&R
'cos I don't know what the digit will be.
So I search, then cancel the search and just insert the ^t at the correct
spot using Selection.TypeText Text:="^t".
However instead of getting a tab, the ^t is exactly what I get as a result.
Can anyone help with this dumb problem? Code follows.
Cheers, Terry
Sub TempDate()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<hr size=1 align=left width=45%>"
.Replacement.Text = "^t<hr size=1 align=left width=45%>^t"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<br>^#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="^t"
Selection.Find.Execute
Wend
End Sub
I'm having what is a problem trying to create a macro that uses tabs, which
will later be used in converting text to a table.
It's fine when I use search and replace to place tabs, using ^t, when I know
exactly what the search will find.
But when I search for a piece of code, followed by a digit, I can't use S&R
'cos I don't know what the digit will be.
So I search, then cancel the search and just insert the ^t at the correct
spot using Selection.TypeText Text:="^t".
However instead of getting a tab, the ^t is exactly what I get as a result.
Can anyone help with this dumb problem? Code follows.
Cheers, Terry
Sub TempDate()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<hr size=1 align=left width=45%>"
.Replacement.Text = "^t<hr size=1 align=left width=45%>^t"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<br>^#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="^t"
Selection.Find.Execute
Wend
End Sub