|
- Sub 单元格数字空格去掉()
- Dim mWord As Document
- Dim mTable As Table
- Dim mCell As Cell
- Dim reg As New RegExp
- With reg
- .Global = False
- .Pattern = "^\s+(-?[\d\.\,]+)\s\x0D\x07$"
- End With
-
- With ThisDocument
- ss = .Tables(1).Cell(3, 2).Range.Text
- For i = 1 To Len(ss)
- ch = Mid(ss, i, 1)
- Debug.Print ch, Asc(ch)
- Next
- For Each mTable In .Tables
- With mTable
- For Each mCell In .Range.Cells
- If reg.Test(mCell.Range.Text) Then
- mCell.Range.Text = reg.Replace(mCell.Range.Text, "$1")
- End If
- Next
- End With
- Next
- End With
- Set mWord = Nothing
- Set mTable = Nothing
- Set mCell = Nothing
- MsgBox "完成!"
- End Sub
复制代码 |
|