使用前,需要在word内插入一个textbox1和一个commandbutton1,然后去掉文档中的标点符号。笔者比较懒,未加入剔除标点的代码。理论上下述代码可以统计999个字符(含标点)的文本,如需增加文本数量,则只需要增加数组体积即可。代码只是通过比较简单的for ,do循环实现,没啥技术含量哈。Sub Button1_click()'统计词频 Dim input_word As Str...
Word VBA自动排版- 通过For循环批量替换代码比较简单,只是在替换的基础上增加了最基础的For循环,有效节省了批量替换文本的时间。废话不多说,直接上代码,Ori = Array("a","b","c") '被替换文本Rep = Array("a","b","c") '替换后的文本For i = 0 To UBound(Ori) With Selection.find ...
Application对象(301) Application.ActivePrinter ‘获取当前打印机(302) Application.Height '当前应用程序文档的高度(303) Application.Width ‘当前应用程序文档的宽度(304) Application.Build ‘获取Word版本号和编译序号(305) Application.Caption ‘当前应用程...
word vba宏在所选内容前插入文字Sub AddTextBeforeSelection()Selection.InsertBefore Text:="你好 www.txttool.com"End Subword vba宏在所选内容后插入文字Sub InsertTextAtEndOfDocument()ActiveDocument.Content.InsertAfter...
word vba宏在活动内容后插入文字Sub InsertTextAtEndOfDocument()ActiveDocument.Content.InsertAfter Text:="你好 www.txttool.com "End Subword vba宏在所选内容前插入文字Sub AddTextBeforeSelection()Selection.InsertBefor...
Sub 删除关键字字符之后的所有内容()Selection.Find.ClearFormattingWith Selection.Find .Text = "中国人" '关键字保留 .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute range1 = Sele...
Sub 删除关键字字符之后的所有内容关键字不保留()Selection.Find.ClearFormattingWith Selection.Find .Text = "中国人" '关键字不保留 .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute range1...
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...
Sub Macro字符串替换() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "讨论" .Replacement.Text = "研讨"End With Selecti...