![]() |
|
#1
|
|||
|
|||
![]()
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .Text = " " .Wrap = wdFindStop While .Execute oRng.Select If MsgBox("Do you want to convert selected text to a single space.", vbYesNo, "Conver") = vbYes Then oRng.Text = " " oRng.Collapse wdCollapseEnd End If Wend End With lbl_Exit: Exit Sub End Sub |
#2
|
|||
|
|||
![]() Quote:
Holy crap. Greg you're a genius, thank you so much for your help!! |
#3
|
|||
|
|||
![]()
Hi Greg
Leading on from this, I am making another version that searches for contractions. However, how can I make it search without matchcase, but replace WITH matchcase? e.g. if it finds "Can't" I want it to replace it with Cannot, not cannot. Sub StyleCheck_ContractionsTest() Dim oRng As Range Set oRng = ActiveDocument.Range Selection.HomeKey Unit:=wdStory With oRng.Find .Text = "can't" .MatchCase = False .Wrap = wdFindStop While .Execute oRng.Select If MsgBox("Do you want to amend the selected contraction?", vbYesNo, "Conver") = vbYes Then oRng.Text = "cannot" oRng.Collapse wdCollapseEnd End If Wend End With MsgBox ("Complete!") lbl_Exit: Exit Sub End Sub |
![]() |
Tags |
vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
wardw | Word | 2 | 09-25-2019 09:19 AM |
This is not a valid selection | edenworkshops | Word | 3 | 09-18-2019 05:43 AM |
![]() |
NobodysPerfect | Word VBA | 3 | 01-14-2015 12:58 PM |
![]() |
ramsgarla | Word VBA | 9 | 12-05-2012 03:23 AM |
How do you add to a selection list? | bryanarn | Excel | 2 | 03-05-2012 05:04 PM |