成品如下,可作为加载宏加载。
RgRyQaem.zip
(12.04 KB, 下载次数: 1888)
以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-3-5 6:50:15 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0174^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Sub SaveAsFileByPage() '分页保存,适用于WORD97及其以上版本 Dim objShell As Object, objFolder As Object, strNameLenth As Integer Dim mySelection As Selection, myFolder As String, myArray() As String Dim ThisDoc As Document, myDoc As Document, strName As String, N As Integer 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" Dim vbYN As VbMsgBoxResult sinStart = Timer On Error GoTo ErrHandle '设置错误处理 '创建一个Shell.Application对象 Set objShell = CreateObject("Shell.Application") '取得文件夹浏览器 Set objFolder = objShell.BrowseForFolder(0, "请选择一个文件夹", 0, 0) If objFolder Is Nothing Then Exit Sub myFolder = objFolder.Self.Path & "\" Set objFolder = Nothing: Set objShell = Nothing Set ThisDoc = ActiveDocument '定义一个Document对象,以利用本程序作为加载宏 Set mySelection = ThisDoc.ActiveWindow.Selection '文件自动命名时必须规避的字符 ErrChar = Array("\", "/", ":", "*", "?", """", "<", ">", "|") '一些特列字符 For N = 0 To 31 ReDim Preserve ErrChar(UBound(ErrChar) + 1) ErrChar(UBound(ErrChar)) = Chr(N) Next
[此贴子已经被作者于2007-3-5 11:56:17编辑过] |