L
LadyMiss22
You guys have really been a big help. This is my first time dealing with
VBA..and the teacher has loved it so far..
I have the following code to replace bold text with whit text, and vice
versa, essentially making the text disappear and re appear. How do I get
the macro to include text in text boxes? It seems to skip over these. Also,
I tried adding a table instead of a text box and the text inside was
converted however this also made the macro "hang" and made Word crash. Any
help would be appreciated.
Dim sLine As String
Dim sTrans As String
Dim sSource As Document
Set sSource = ActiveDocument
Flag = False
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorWhite
With Selection.Find
If .Execute = True Then
Flag = True
End If
Do While .Execute(FindText:="", MatchWildcards:=False, MatchCase:=True,
Wrap:=wdFindContinue, Forward:=True) = True
With Selection.Font
..Color = wdColorAutomatic
..Bold = True
End With
Loop
End With
If Flag = True Then
sTrans = 1#
sLine = msoFalse
With sSource
For Each aShape In .Shapes
If aShape.Type = msoTextEffect Then
aShape.Select
With Selection
..ShapeRange.Fill.Transparency = sTrans
..ShapeRange.Line.Visible = sLine
End With
End If
Next aShape
End With
Exit Sub
Else
sTrans = 0#
sLine = msoTrue
End If
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorAutomatic
Selection.Find.Font.Bold = True
With Selection.Find
Do While .Execute(FindText:="", MatchWildcards:=False, MatchCase:=True,
Wrap:=wdFindContinue, Forward:=True) = True
With Selection.Font
..Color = wdColorWhite
End With
Loop
End With
With sSource
For Each aShape In .Shapes
If aShape.Type = msoTextEffect Then
aShape.Select
With Selection
..ShapeRange.Fill.Transparency = sTrans
..ShapeRange.Line.Visible = sLine
End With
End If
Next aShape
End With
End Sub
VBA..and the teacher has loved it so far..
I have the following code to replace bold text with whit text, and vice
versa, essentially making the text disappear and re appear. How do I get
the macro to include text in text boxes? It seems to skip over these. Also,
I tried adding a table instead of a text box and the text inside was
converted however this also made the macro "hang" and made Word crash. Any
help would be appreciated.
Dim sLine As String
Dim sTrans As String
Dim sSource As Document
Set sSource = ActiveDocument
Flag = False
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorWhite
With Selection.Find
If .Execute = True Then
Flag = True
End If
Do While .Execute(FindText:="", MatchWildcards:=False, MatchCase:=True,
Wrap:=wdFindContinue, Forward:=True) = True
With Selection.Font
..Color = wdColorAutomatic
..Bold = True
End With
Loop
End With
If Flag = True Then
sTrans = 1#
sLine = msoFalse
With sSource
For Each aShape In .Shapes
If aShape.Type = msoTextEffect Then
aShape.Select
With Selection
..ShapeRange.Fill.Transparency = sTrans
..ShapeRange.Line.Visible = sLine
End With
End If
Next aShape
End With
Exit Sub
Else
sTrans = 0#
sLine = msoTrue
End If
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorAutomatic
Selection.Find.Font.Bold = True
With Selection.Find
Do While .Execute(FindText:="", MatchWildcards:=False, MatchCase:=True,
Wrap:=wdFindContinue, Forward:=True) = True
With Selection.Font
..Color = wdColorWhite
End With
Loop
End With
With sSource
For Each aShape In .Shapes
If aShape.Type = msoTextEffect Then
aShape.Select
With Selection
..ShapeRange.Fill.Transparency = sTrans
..ShapeRange.Line.Visible = sLine
End With
End If
Next aShape
End With
End Sub