乔山办公网我们一直在努力
您的位置:乔山办公网 > word文档 > 请教怎样利用<em>VBA</em>获取<em>Word</em>中某种

请教怎样利用<em>VBA</em>获取<em>Word</em>中某种

作者:乔山办公网日期:

返回目录:word文档


Public StartPageNum As Integer, EndPageNum As Integer

Sub aaa()

Dim myDialog As FileDialog, oFile As Variant, oDoc As Document
On Error Resume Next

Set myDialog = Application.FileDialog(msoFileDialogFilePicker)

myDialog.Filters.Clear '清除所有文件筛选器中的项目
myDialog.Filters.Add "所有 WORD 文件", "*.doc", 1 '增加筛选器的项目为所有WORD文件
myDialog.AllowMultiSelect = True '允许多项选择e799bee5baa6e997aee7ad94e58685e5aeb9334

If myDialog.Show <> -1 Then Exit Sub

Dim SelectRange As Range
DlgDelePage.Show vbModal
If StartPageNum = 0 And EndPageNum = 0 Then
Exit Sub
End If

For Each oFile In myDialog.SelectedItems '在所有选取项目中循环

Set oDoc = Documents.Open(FileName:=oFile, Visible:=True) 'False)

Dim Pages As Integer, StartPage As Long, EndPage As Long

Pages = Selection.Information(wdNumberOfPagesInDocument)

If Not (StartPageNum > Pages) Then
If EndPageNum > Pages Then EndPageNum = Pages

If StartPageNum = 1 Then
StartPage = Selection.Range
Else
StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=StartPageNum - 1).Start
End If

If EndPageNum = Pages Then
EndPage = ActiveDocument.Content.End
Else
EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=IIf(EndPageNum - StartPageNum > 0, EndPageNum - StartPageNum + 1, 1)).End '.Start
End If

ActiveDocument.Range(StartPage, EndPage).Select
Selection.Delete

End If

'删除第3页批注
ActiveDocument.Words(1).Select '将光标移到文档开始位置
Dim myRange As Range, oComment As Comment
Set myRange = Selection.Range
StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).Start
EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).End

myRange = ActiveDocument.Range(StartPage, EndPage)

If myRange.Comments.Count > 0 Then
For Each oComment In myRange.Comments
oComment.Delete
Next
End If

oDoc.Save
oDoc.Close

Next oFile

End Sub

前提你有vba 变程的基础知识,定义你的宏
sub setBG()
ActiveDocument.Background.Fill.UserPicture "C:\BG.bmp"
end Sub

就可以将背景 改为 C:\BG.bmp
UserPicture 方法参阅应用于示例特性
用一张图片的大图像来填充指定图形。如果要用一个图片的多份影像来填充图形,请用 UserTextured 方法。
expression.UserPicture(PictureFile)
expression 必需。返回 FillFormat 对象的表达式。
PictureFile String 类型,必需。图片文件名
ctrl+g 然后定位条件-公式- 删除

Application.Run("SelectSimilarFormatting");

相关阅读

  • 通过<em>VBA</em>如何修改<em>WORD页眉</em>??-

  • 乔山办公网word文档
  • 打开带有页眉页脚的word文档,双击页来眉,在页眉处右键单击,单击“边框和底纹”,将边框设置为”无“,单击面板下面的“应用于”长方形条框,将自改为”图片“改为”段落“,
  • 我在<em>word</em> <em>vba</em> 环境下,怎么可

  • 乔山办公网word文档
  • 代码已经测试过,请注意保持良好习惯,及时采纳,谢谢。Sub PasteToWordDoc() 需要引用MIcrosoft Word 12.0 Object Library(注:12.0是版本号,可以不同) Application.ScreenUpdating = False 关闭屏幕刷
  • -word vba 域,vba word

  • 乔山办公网word文档
  • 主要功能:通用VB6编写通用的类,给用户提供可视化的编辑界面,用于用户在Word文件zhidao中插入域标志。针对Word文件或Excel表格文件,扫描整个文件,将其中的域标志(如Set “aaa”)取
关键词不能为空
极力推荐
  • word打不开-Word打不开的解决办法,太管用了!

  • 大部分人使用word可能都遇到过这样的情况,就是Word自己关闭报错,如下图所示:这时候你如果选择“不发送”,然后重启,就会进入安全模式,安全模式下无法通过双击word文件的方式

ppt怎么做_excel表格制作_office365_word文档_365办公网