Skip to content

Instantly share code, notes, and snippets.

@TwistingTwists
Last active May 13, 2020 03:40
Show Gist options
  • Save TwistingTwists/48be80ea2c7fa83f67e38a86013f2db8 to your computer and use it in GitHub Desktop.
Save TwistingTwists/48be80ea2c7fa83f67e38a86013f2db8 to your computer and use it in GitHub Desktop.
Useful Commands for word macro

this sets white Black to text

Sub WhiteToBlackText()
'
' WhiteToBlackText Macro
'
'

    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorWhite
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRose
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub

this one sets all textbox with color to no background color

Sub BoxNoColor()
'
' BoxNoColor Macro
'
ActiveDocument.Content.ShapeRange.Fill.ForeColor.RGB = _
    RGB(255, 255, 255)

End Sub

too lazy to see what was implemented what aws not, here is new version from 12-05-2020


Sub BoxNoColor()
'
' BoxNoColor Macro
'
ActiveDocument.Content.ShapeRange.Fill.ForeColor.RGB = _
    RGB(255, 255, 255)

End Sub
Sub BlacktextTextBox()
'
' BlacktextTextBox Macro
'
'
Dim oShp As Shape


  For Each oShp In ActiveDocument.Shapes
  
      If oShp.Type = msoTextBox Then
      
       oShp.TextFrame.TextRange.Font.ColorIndex = wdBlack
       

    
  

    End If
  
Next oShp


End Sub
Sub WhiteToBlackText()
'
' WhiteToBlackText Macro
'
'

    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorWhite
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorYellow
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub
Sub RemoveTextHiglight()
'
' RemoveTextHiglight Macro
'
'
    'Macro created by Stefan Blom, MVP, January 2015

    With ActiveDocument.Content.ParagraphFormat.Shading
        .Texture = wdTextureNone
        .ForegroundPatternColor = wdColorAutomatic
        .BackgroundPatternColor = wdColorAutomatic
    End With
   
    With ActiveDocument.Content.Font.Shading
        .Texture = wdTextureNone
        .ForegroundPatternColor = wdColorAutomatic
        .BackgroundPatternColor = wdColorAutomatic
    End With



End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment