Word 宏VBA全角转换为半角

180it 2019-09-25 PM 4664℃ 0条

Sub 全角转换为半角()

'使用前需先选中要替换的区域
Dim fullshape, halfshape As String, i As Integer '定义fullshape(全角)、halfshape(半角)为字符串型,i为整数型
fullshape = "A、B、C、D、"
halfshape = "A.B.C.D."
For i = 1 To 10 '循环10次
With Selection.Find
.Text = Mid(fullshape, i, 1) 'mid函数:返回文本字符串中从指定位置开始的特定数目的字符,每次取一个标点符号
.Replacement.Text = Mid(halfshape, i, 1) '将用于替换的相应位置的半角标点符号
.Format = False '保留替换前的字符格式
.Execute Replace:=wdReplaceAll '用半角标点替换全角标点
End With
Next i

End Sub

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

Word 宏VBA全角转换为半角