IT袋

当前位置:主页 > 经验教程 > 办公教程 >

wordvba编程代码大全

word vba编程 wordvba编程代码大全(2)

更新:2023-06-30 17:28:08 来源:IT袋 作者:马勇
导读:wordvba编程代码大全,Exit Sub '如果用户选择了取消按钮,则退出程序运行  Case vbYes '如果用户选择了YES,则将中文标点转换为英文标点  myArray1 = ChineseInterpunction  myAr

wordvba编程代码大全

Exit Sub '如果用户选择了取消按钮,则退出程序运行 

Case vbYes '如果用户选择了YES,则将中文标点转换为英文标点 

myArray1 = ChineseInterpunction 

myArray2 = EnglishInterpunction strFind = "“(*)”" 

strRep = """\1""" Case vbNo '如果用户选择了NO,则将英文标点转换为中文标点 myArray1 = EnglishInterpunction myArray2 = ChineseInterpunction 

strFind = """(*)""" 

strRep = "“\1”" 

End Select 

Application.ScreenUpdating = False '关闭屏幕更新 

For N = 0 To UBound(ChineseInterpunction) '从数组的下标到上标间作一个循环 

With ActiveDocument.Content.Find 

.ClearFormatting '不限定查找格式 

.MatchWildcards = False '不使用通配符 

'查找相应的英文标点,替换为对应的中文标点 

.Execute findtext:=myArray1(N), replacewith:=myArray2(N), Replace:=wdReplaceAll 

End With 

Next

With ActiveDocument.Content.Find 

.ClearFormatting '不限定查找格式 

.MatchWildcards = True '使用通配符 

.Execute findtext:=strFind, replacewith:=strRep, Replace:=wdReplaceAll 

End With 

Application.ScreenUpdating = True '恢复屏幕更新 

End Sub  

4、任意页插入页码 

Sub任意页插入页码() 

Dim p As Integer 

On Error Resume Next 

p = InputBox("请输入起始编排页码的页次") 

With Selection 

.GoTo What:=wdGoToPage, Count:=p 

.InsertBreak Type:=wdSectionBreakContinuous 

.Sections(1).Footers(1).LinkToPrevious = False 

With .Sections(1).Footers(1).PageNumbers 

.RestartNumberingAtSection = True .StartingNumber = 1 

.Add PageNumberAlignment:=wdAlignPageNumberCenter, FirstPage:=True 

End With 

End With 

End Sub  

5、实现图形的精确旋转 

Sub 图形旋转() 

Dim blnIsInlineShape As Boolean 

If Selection.Type = wdSelectionInlineShape Then 

blnIsInlineShape = True 

Selection.InlineShapes(1).ConvertToShape 

End If 

Dim intTurn As Integer 

intTurn = InputBox("请输入图形要旋转的角度值" & vbCrLf & "正数表示顺时针,负数表示逆时针。", "图形旋转", 30) 

Selection.ShapeRange.IncrementRotation intTurn 

End Sub 

上述就是wordvba编程代码大全,可以给你更高的使用效率,想知道更多的教程继续的关注IT袋网哦。

本文分享的 wordvba编程代码大全的IT小知识讲解,希望为您的生活带来一点小帮助!

相关阅读