|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub getHeaderString()
- Dim se As Section, doc As Document, sr$, hp As Shape, p As Range
- Set doc = ActiveDocument: Set p = doc.Content
- If p.Find.Execute("页眉内容") Then
- p.SetRange p.Start, doc.Content.End
- p.Delete
- End If
- For Each se In doc.Sections
- For i = 1 To 3
- For Each hp In se.Headers(i).Range.ShapeRange
- sr = sr & vbCr & hp.TextFrame.TextRange.Text
- Next
- Next
- Next
- doc.Content.InsertAfter vbCr & "页眉内容" & sr
- MsgBox "获取的页眉内容已插入文档末尾!"
- End Sub
复制代码
|
|