word vba宏在活动内容后插入文字

word vba宏在活动内容后插入文字

word vba宏在活动内容后插入文字Sub InsertTextAtEndOfDocument()ActiveDocument.Content.InsertAfter Text:="你好 www.txttool.com "End Subword vba宏在所选内容前插入文字Sub AddTextBeforeSelection()Selection.InsertBefore Text:="你好 www.txttool.com"End SubRange对象或 Selection对象在使用了 InsertBefore 或 InsertAfter方法之后...

VBA 2019-09-25 PM 1412℃ 0条
word vba宏在所选内容前插入文字

word vba宏在所选内容前插入文字

word vba宏在所选内容前插入文字Sub AddTextBeforeSelection()Selection.InsertBefore Text:="你好 www.txttool.com"End Subword vba宏在所选内容后插入文字Sub InsertTextAtEndOfDocument()ActiveDocument.Content.InsertAfter Text:="你好 www.txttool.com "End SubRange对象或 Selection对象在使用了 InsertBefore 或 InsertAfter方法之后...

VBA 2019-09-25 PM 1622℃ 0条
word vba宏删除关键字字符之后的所有内容关键字保留

word vba宏删除关键字字符之后的所有内容关键字保留

Sub 删除关键字字符之后的所有内容()Selection.Find.ClearFormattingWith Selection.Find .Text = "中国人" '关键字保留 .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute range1 = Selection.End Selection.Find.Execute range2 = Selection.Start ActiveDocument.Range(range1).Delete 'Activ...

VBA 2019-09-25 PM 1594℃ 0条
word vba宏删除关键字字符之后的所有内容关键字不保留

word vba宏删除关键字字符之后的所有内容关键字不保留

Sub 删除关键字字符之后的所有内容关键字不保留()Selection.Find.ClearFormattingWith Selection.Find .Text = "中国人" '关键字不保留 .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute range1 = Selection.End Selection.Find.Execute range2 = Selection.Start ActiveDocument.Range(range2).Delete...

VBA 2019-09-25 PM 1934℃ 0条
Word 宏VBA全角转换为半角

Word 宏VBA全角转换为半角

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函数:返回文本字符串中从指定位置开始的特定数目的字符,每次取一个标点符号...

VBA 2019-09-25 PM 3291℃ 0条
word 宏vba 批量字符串替换

word 宏vba 批量字符串替换

Sub Macro字符串替换() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "讨论" .Replacement.Text = "研讨"End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub

VBA 2019-09-25 PM 3583℃ 0条
word 宏VBA实现查找内容字体替换字体

word 宏VBA实现查找内容字体替换字体

Sub ChaFontName()With ActiveDocument.Content.Find.ClearFormatting.Font.Name = "Times New Roman" '查找宋体'.Font.Size = "小四"With .Replacement.ClearFormatting.Font.Name = "宋体" '替换成楷体.Font.Size = "10"End With.Execute FindText:="A", ReplaceWith:="A", Format:=True, Replace:=wdReplaceAllEnd WithEnd...

VBA 2019-09-25 PM 3801℃ 0条
Word 宏VBA对整个内容行进行排序

Word 宏VBA对整个内容行进行排序

Word VBA对整个内容行进行排序Sub SortText()' A macro to sort the selected text Selection.SortEnd Sub

VBA 2019-09-25 PM 2664℃ 0条
Word 宏VBA对两个文本段排序

Word 宏VBA对两个文本段排序

Word VBA对两个文本段排序Sub SortText2()' A macro to sort the Selection if the user has selected more than one ' paragraph of text. If Selection.Paragraphs.Count > 1 Then Selection.Sort End IfEnd Sub

VBA 2019-09-25 PM 1469℃ 0条
word 宏VBA实现统计行

word 宏VBA实现统计行

Sub lineCount()'统计行数Dim wordCount, lineCount Set myRange = Selection.Range lineCount = myRange.ComputeStatistics(Statistic:=wdStatisticLines) MsgBox lineCount End Sub

VBA 2019-09-25 PM 2098℃ 0条
VBA sub 与 function 的区别

VBA sub 与 function 的区别

sub称为过程, function称为函数,他们之间的唯一区别是function有返回值。完全可以把sub写成function,只要不用function的返回值就可以了。C语言就只有函数而没有过程,因此一般情况下都可以用function来代替sub。但这两段代码对于excel的运行位置不同。sub会出现在宏里,而function会出现在插入函数中。Function Sqr_Function()Dim i As Integer i = 5 Dim iResult As Integer iResult = i * i Debug.Print iResultEnd FunctionSub Sq...

VBA 2019-09-25 PM 4018℃ 0条