vba - MS Word VBA 链接多个部分和页面的上一个页脚
问题描述
我有一个 MS Word (2010),我的文档有数百个部分,而我真的只需要有限数量的具有相同页脚的部分。
我想要一个可以循环浏览所选页面并将所有页脚更改为链接到上一个的宏。
我录制了一个宏,它将为一个部分执行此操作,如何更改代码,以便如果我选择了一堆页面(例如 25 个),它将压缩所有页面?
Sub LinkToPrev_Foot()
'
' LinkToPrev_Foot Macro
'
'
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
' ActiveWindow.ActivePane.View.NextHeaderFooter
End Sub
解决方案
您需要遍历文档的各个部分。下面的代码假定您只使用三种类型的页脚中的一种。
Public Sub LinkToPrev_Foot()
Dim ftr As HeaderFooter
Dim sec As Section
For Each sec In ActiveDocument.Sections
'can't link the first section to a previous one
If sec.Index > 1 Then
'if document has other types of footer you'll need to loop through them
sec.Footers(wdHeaderFooterPrimary).LinkToPrevious = True
End If
Next sec
End Sub
推荐阅读
- gnuplot - 从空 gnuplot 点的中心移除点
- asp.net-mvc-5 - ASP.NET MVC 5 DACPAC Sql140DatabaseSchemaProvider 无效
- iptables - iptables geoip 从被阻止的国家/地区排除单个 IP
- xml - 如何从网页将 XML 导入 Google 表格
- mysql - 查询日期范围“01-01-2019”和“02-02-2019”不起作用
- asp.net-mvc - 版本号的asp.net mvc视图模型验证
- php - 在 wp-ajax.php 中发现可能的盲 SQL 注入错误
- c++ - SFINAE:派生类隐藏基类函数依赖于T
- javascript - 在我的自定义 wordpress 模板上进行两级切换
- javascript - 如何在 javascript 中显示 html 文件?