G
Guillermo
Hello everyone,
I'm sorry if I'm asking something obvious, but I'm at lost with this.
In the line
..Text = b & "[[" & a & " (md)]]"
below I'd like to apply different formats to b, "[[" and " (md)]]" and b (i. e.
different font colors, etc).
Is it possible to format this text before adding it to the document (before the
replace command is executed)?
Thanks,
Guillermo
Here's a snippet of my code:
<code>
Sub MergeTerms(a As Variant, b As Variant)
Dim rango1 As Range
Set rango1 = Documents(TargetDoc).Range
With rango1.Find
.ClearFormatting
.Font.Hidden = False
.Text = a
With .Replacement
If FormatSp = "AllUpper" Then
'StrConv permite transformar una cadena
.Text = StrConv(b, vbUpperCase) & "[[" & a & " (gr)]]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
ElseIf FormatSp = "AllBold" Then
.Text = b & "[[" & a & " (md)]]"
.Font.Bold = True
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
Else
.Text = b & "[[" & a & "]]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
End If
End With
.Execute Format:=True, Replace:=wdReplaceAll
End With
With Documents(TargetDoc).Range.Find
.ClearFormatting
.Font.Hidden = False
.Text = "\[\[" & "*" & "\]\]"
With .Replacement
.Text = "^&"
With .Font
.Hidden = True
.Color = wdColorBrown
.Underline = wdUnderlineNone
End With
End With
.Execute Format:=True, Replace:=wdReplaceAll, MatchWildcards:=True
End With
End Sub
Sub deleteunderline()
Dim rango1 As Range
Set rango1 = ActiveDocument.Range
With rango1.Find
.Format = True
'.MatchWildcards = True
'.text = "\[\[*\]\]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
With .Replacement
.Text = "^&"
'.Font.Color = wdColorDarkRed
.Font.Underline = wdUnderlineNone
'.Font.Hidden = True
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
<end of code>
I'm sorry if I'm asking something obvious, but I'm at lost with this.
In the line
..Text = b & "[[" & a & " (md)]]"
below I'd like to apply different formats to b, "[[" and " (md)]]" and b (i. e.
different font colors, etc).
Is it possible to format this text before adding it to the document (before the
replace command is executed)?
Thanks,
Guillermo
Here's a snippet of my code:
<code>
Sub MergeTerms(a As Variant, b As Variant)
Dim rango1 As Range
Set rango1 = Documents(TargetDoc).Range
With rango1.Find
.ClearFormatting
.Font.Hidden = False
.Text = a
With .Replacement
If FormatSp = "AllUpper" Then
'StrConv permite transformar una cadena
.Text = StrConv(b, vbUpperCase) & "[[" & a & " (gr)]]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
ElseIf FormatSp = "AllBold" Then
.Text = b & "[[" & a & " (md)]]"
.Font.Bold = True
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
Else
.Text = b & "[[" & a & "]]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
End If
End With
.Execute Format:=True, Replace:=wdReplaceAll
End With
With Documents(TargetDoc).Range.Find
.ClearFormatting
.Font.Hidden = False
.Text = "\[\[" & "*" & "\]\]"
With .Replacement
.Text = "^&"
With .Font
.Hidden = True
.Color = wdColorBrown
.Underline = wdUnderlineNone
End With
End With
.Execute Format:=True, Replace:=wdReplaceAll, MatchWildcards:=True
End With
End Sub
Sub deleteunderline()
Dim rango1 As Range
Set rango1 = ActiveDocument.Range
With rango1.Find
.Format = True
'.MatchWildcards = True
'.text = "\[\[*\]\]"
.Font.Underline = wdUnderlineDouble
.Font.UnderlineColor = wdColorBlue
With .Replacement
.Text = "^&"
'.Font.Color = wdColorDarkRed
.Font.Underline = wdUnderlineNone
'.Font.Hidden = True
End With
.Execute Replace:=wdReplaceAll
End With
End Sub
<end of code>