12 replies
by eraser3498
by rob miners
Pressing F1 while in word and lookup "Macro" will give you details. Below is a sample.
Sub delall()
'
' delall Macro
' Macro recorded 2/12/2005 by rrjmin0
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Wi-Fi "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
by eraser3498
by bschaettle
This isn't a complete solution, but here's some code I have that will clear the current line:
Sub ClearCurrentLine()
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
If Selection.Characters.Count = 1 And _
Asc(Selection.Characters(1)) = 13 Then Exit Sub
On Error Resume Next
Selection.Delete Unit:=wdCharacter, Count:=1
On Error GoTo 0
End Sub
by eraser3498
by rkelly
by eraser3498
by aakash shah
Another simpler, yet very effective approach would be to use the find and replace tool in MS Word. For example, if the word you are trying to remove is "bad_word". Then, click Edit | Replace and type in "bad_word" into the Find What field. Keep the Replace With field blank and then click Replace All. Note that you can choose more advanced options to choose advanced pieces of text also by clicking on More in the Find and Replace window.
Hope this helps.
by eraser3498
by bschaettle
OK, here's a complete solution:
Sub ClearLines()
'
' ClearLines Macro
'
Dim sTargetText As String
Dim bStringFound As Boolean
sTargetText = InputBox("Please enter the text you want deleted", "title")
If Len(sTargetText) = 0 Then Exit Sub
Do
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = sTargetText
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
bStringFound = Selection.Find.Execute
If bStringFound Then
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.TypeParagraph
Selection.TypeParagraph
End If
Loop While bStringFound
End Sub ' ClearLines
by eraser3498
by eraser3498
This discussion is closed to new replies.
Trending Software posts
Sort by Trending