做了一个适用于WORD 2003及其以上版本的程序,具有一定通用性,可作为加载宏使用。
ogi2GYhw.rar
(26.32 KB, 下载次数: 704)
以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-3-3 17:15:24 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0172^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Sub SaveAsFileByPage() Dim ThisDoc As Document, myDoc As Document, oPage As Page, strName As String Dim myDialog As FileDialog, myFolder As String, myArray() As String Dim myRange As Range, PageString As String, pgOrientation As WdOrientation Dim sinLeft As Single, sinRight As Single, sinTop As Single, sinBottom As Single Dim ErrChar() As Variant, oChar As Variant, sinStart As Single, sinEnd As Single Const myMsgTitle As String = "ExcelHome_ShouRou" If Val(Application.Version) < 11 Then MsgBox "此程序需要运行在Word 2003及其以上版本中!", vbInformation, myMsgTitle: Exit Sub sinStart = Timer On Error GoTo ErrHandle '设置错误处理 '定义一个FileDialog对象,为文件夹选取对话框 Set myDialog = Application.FileDialog(msoFileDialogFolderPicker) With myDialog If .Show <> -1 Then Exit Sub '如果未确定则退出 myFolder = .InitialFileName '取得文件夹路径 End With Application.ScreenUpdating = False '关闭屏幕更新 Set ThisDoc = ActiveDocument '定义一个Document对象,以利用本程序作为加载宏 '文件自动命名时必须规避的字符 ErrChar = Array("\", "/", ":", "*", "?", """", "<", ">", "|") '在文档的每页中循环
|