View Single Post
 
Old 09-13-2015, 08:51 AM
peligroso peligroso is offline Windows 8 Office 2013
Novice
 
Join Date: Sep 2015
Posts: 6
peligroso is on a distinguished road
Default vba find numbers in document and align text left

I am calling a embedded word document from excel and populating it with tables from excel with financial data to produce a report.

When the tables are copied into word the numbers contain leading spaces that are spoiling the formatting. I have written the code to strip out the leading spaces however the data is still left justified rather than right justified.

I am trying to use the following code using wildcards to locate any financial numbers and left justify them however I am off the mark as the code 1) removes the financial numbers and 2) does not justify.

With wrdObj
.Content.SelectAll
With .Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "*.[0-9][0-9]"
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
If .Found = True Then .Parent.Font.Alignment = wdAlignParagraphRight
End With
End with


Any help appreciated.
Reply With Quote