|
* 楼主,Word2003 的宏代码可以按 Alt + F11 进入 VBE 后,按 Ctrl + A 全选,复制,粘贴到一个记事本文件中即可,然后,打开 Word2016,同样进入 VBE 后,按 Ctrl + End 在代码的最后部分,粘贴上刚才记事本中的宏代码。
* Word2003 的自动图文集词条的备份与还原,请试用下面的宏:(代码粘贴到 Normal.dot 通用模板中)
- Sub 自动图文集_备份与还原()
- Dim i As AutoTextEntry, s$
- If MsgBox("<是>:备份 <否>:还原", 4 + 16, "自动图文集") = vbYes Then
- Documents.Add
- For Each i In NormalTemplate.AutoTextEntries
- Selection.TypeText Text:=i.Name & vbCr
- ActiveDocument.Content.Select
- Selection.Collapse Direction:=wdCollapseEnd
- i.Insert Where:=Selection.Range, RichText:=True
- Selection.TypeText Text:="```" & vbCr
- Next
- With ActiveDocument
- .Paragraphs.Last.Range.Delete
- .SaveAs FileName:="D:\自动图文集备份.doc"
- .Close
- End With
- MsgBox "自动图文集备份完毕!共有词条 " & NormalTemplate.AutoTextEntries.Count & " 个!" & vbCr & _
- "备份文件 D:\自动图文集备份.doc" & vbCr & "请将备份复制到任意电脑上的 D 盘根下应用本宏可恢复自动图文集!", 0 + 48
- Else
- If Dir("D:\自动图文集备份.doc") = "" Then MsgBox "备份不存在!", 0 + 16: End
- Documents.Open FileName:="D:\自动图文集备份.doc"
- With Selection
- .HomeKey Unit:=wdStory
- Do
- s = .Paragraphs(1).Range.Text
- s = Left(s, Len(s) - 1)
- .MoveEndUntil cset:="```"
- .MoveStart Unit:=wdParagraph, Count:=1
- NormalTemplate.AutoTextEntries.Add Range:=.Range, Name:=s
- .Move Unit:=wdParagraph, Count:=2
- If .Paragraphs(1).Range.End = ActiveDocument.Content.End Then Exit Do
- Loop
- End With
- ActiveDocument.Close savechanges:=wdDoNotSaveChanges
- MsgBox "自动图文集还原完毕!共有词条 " & NormalTemplate.AutoTextEntries.Count & " 个!", 0 + 48
- End If
- End Sub
复制代码 |
|