D
dvdastor
Hi All,
I am starting to get the hang of this Word Automation thing, but this
issue has me puzzled to no end.
I have the following text in my document:
[~Alternative~]by installing SQL Server 2000 as a named instance on the
same computer<Shift+Enter>
[~CorrectAnswer~]by installing SQL Server 2000 as a default instance on
another computer<Enter>
I am setting my range to include just the first line, but only the text
between the "]" and the line break. I am then attempting to apply
formatting to that text. If the text contains Arial font, I need it to
look like the following:
<font face='Arial'>by installing SQL Server 2000 as a named instance on
the same computer</font>
However, whenever I run my macro, it ignores my selection and applies
the formatting to the entire thing like so:
[~Alternative~]<font face="Arial">by installing SQL Server
2000 as a named instance on the same computer<Shift+Enter>
[~CorrectAnswer~]by installing SQL Server 2000 as a default instance on
another computer</font><Enter>.
Here is the macro I am using:
Public Function ReturnString()
Dim rngResult As Range
Dim myRange As Range
Set rngResult = ActiveDocument.Range
Set myRange = rngResult.Duplicate
With myRange
.Start = 15
.End = 85
End With
myRange.Select
With myRange.Find
.ClearFormatting
.Font.Name = "Arial"
.Replacement.ClearFormatting
.Wrap = wdFindStop
.Execute findtext:="", ReplaceWith:="<font
face="Arial">^&</font>", Format:=True,
Replace:=Word.WdReplace.wdReplaceAll
End With
myRange.Select
End Function
Can anyone help with this?
I am starting to get the hang of this Word Automation thing, but this
issue has me puzzled to no end.
I have the following text in my document:
[~Alternative~]by installing SQL Server 2000 as a named instance on the
same computer<Shift+Enter>
[~CorrectAnswer~]by installing SQL Server 2000 as a default instance on
another computer<Enter>
I am setting my range to include just the first line, but only the text
between the "]" and the line break. I am then attempting to apply
formatting to that text. If the text contains Arial font, I need it to
look like the following:
<font face='Arial'>by installing SQL Server 2000 as a named instance on
the same computer</font>
However, whenever I run my macro, it ignores my selection and applies
the formatting to the entire thing like so:
[~Alternative~]<font face="Arial">by installing SQL Server
2000 as a named instance on the same computer<Shift+Enter>
[~CorrectAnswer~]by installing SQL Server 2000 as a default instance on
another computer</font><Enter>.
Here is the macro I am using:
Public Function ReturnString()
Dim rngResult As Range
Dim myRange As Range
Set rngResult = ActiveDocument.Range
Set myRange = rngResult.Duplicate
With myRange
.Start = 15
.End = 85
End With
myRange.Select
With myRange.Find
.ClearFormatting
.Font.Name = "Arial"
.Replacement.ClearFormatting
.Wrap = wdFindStop
.Execute findtext:="", ReplaceWith:="<font
face="Arial">^&</font>", Format:=True,
Replace:=Word.WdReplace.wdReplaceAll
End With
myRange.Select
End Function
Can anyone help with this?