'* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-8-1 6:55:35 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0044^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Private Sub CommandButton1_Click() Dim strTitle As String, strSubject As String, strCategory As String Dim myTable As Table, myRange As Range With ActiveDocument Set myTable = .Tables(1) '定义为表格1 With myTable Set myRange = .Cell(1, 3).Range myRange.SetRange myRange.Start, myRange.End - 1 strTitle = myRange.Text '取得标题文本 Set myRange = .Cell(1, 4).Range myRange.SetRange myRange.Start, myRange.End - 1 strCategory = myRange.Text '取得类别文本 End With Set myTable = .Tables(2) '定义为表格2 With myTable Set myRange = .Cell(1, 2).Range myRange.SetRange myRange.Start, myRange.End - 1 strSubject = myRange.Text '取得主题文本 End With '以下设置要求的文档属性值:标题\主题\类别 .BuiltInDocumentProperties(wdPropertyTitle) = strTitle .BuiltInDocumentProperties(wdPropertySubject) = strSubject .BuiltInDocumentProperties(wdPropertyCategory) = strCategory .SaveAs FileName:=strTitle & strSubject End With End Sub 把按钮自定义到活动文档的工具栏中不是更好吗?或者直接修改WORD的保存命令即可。没有必要把“更名保存文件”以命令控件形式放在单元格中。 |