Using Word macro (wizzardry), how do I add 4807 to selected text?

J

John

Hi

- The first step would be to add 4807 to the number
- the next step would be to put a line through that text (i.e make it
strikeout) and put the new number next to it.


i.e. if I was to highlight '17741', it would make '17741' strikeout
and then put 22548 next to it.


Thanks
John
 
G

Greg Maxey

Sub ScratchMacro()
Dim oRng As Word.Range
Dim lngSum As Long
Dim pStr As String
Dim i As Long
Set oRng = Selection.Range
With oRng
If IsNumeric(.Text) Then
lngSum = .Text + 4807
pStr = CStr(lngSum)
.Font.StrikeThrough = True
.Collapse wdCollapseEnd
i = .Start
.InsertAfter pStr
.Font.StrikeThrough = False
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top