WORD 2010编辑标头和宏页脚 [英] WORD 2010 Macro for Editing Headers & Footers

查看:312
本文介绍了WORD 2010编辑标头和宏页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有基本的VBA经验,而我以前的Macro经验主要是WORD2003.记录宏用于GoToFooter(或"Edit Footer")菜单命令并允许后续编辑.在WORD 2010中,此命令(以及许多其他命令)不会记录"到宏(但是在记录"模式下,我确实进入了编辑页脚"功能).

I have only basic VBA experince and my prior Macro experence was primarily with WORD 2003. Recording Macros used to take GoToFooter (or Edit Footer) Menu Commands and allow subsequent editing. In WORD 2010, this (and many other) commands do not "record" to the Macro (yet when in Record mode, I do get into Edit Footer function).

对各种VBS选项的研究显示了创建页脚和在Macro中进行全局页脚设置更改的几种方法.但是,如果仅想在页脚中修改公司名称(例如),则无法在Macro子例程中找到此方法.

A research of various VBS options shows several ways to create Footers and to make global Footer setting changes within Macro. However If I simply want to Revise the Company name within the Footer (for example), I can find no way to do this within a Macro subroutine.

此子例程是我从主宏调用的子例程,该宏正在逐步遍历Folder(&子文件夹)中的每个文件.我有主要的Macro功能.

This subroutine is one that I would call from the Main Macro that is stepping through each file in a Folder (& subfolders). I have the main Macro functioning.

WORD 2010 Macro-VBA是否排除了简单的编辑页脚功能?

Does WORD 2010 Macro-VBA preclude simple Edit-Footer function?

预先感谢

因此,感谢Issun,这是我的解决方案:

So, thanks to Issun, here is my solution:

`
Sub Sub_FTR_0()
'
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

For i = 1 To ActiveDocument.Sections.Count
 'REM: INSERT Code from RECORD MACRO recorded when editing one Footer correctly
    Selection. [[xxx]], etc.

If i = ActiveDocument.Sections.Count Then GoTo Line1

    ActiveDocument.ActiveWindow.ActivePane.View.NextHeaderFooter

Line1:
Next

    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

End Sub
`

推荐答案

在这里,您可以通过VBA访问页眉/页脚.如您所见,:p there

Here is a way you can access the headers/footers via VBA. As you can see, it's rather complicated syntax to get to something so simple :p there

Sub EditHeadersAndFooters()

Dim i As Long

For i = 1 To ActiveDocument.Sections.Count
    With ActiveDocument.Sections(i)
        .Headers(wdHeaderFooterPrimary).Range.Text = "Foo"
        .Footers(wdHeaderFooterPrimary).Range.Text = "Bar"
    End With
Next

End Sub

这里是示例代码的链接,该示例代码介绍了如何更改文件夹中每个文件中的标头.它采用了不同的方法,但我从未尝试过,但仅供参考: http: //www.vbaexpress.com/kb/getarticle.php?kb_id=45

Here is a link to example code on how to change the headers in every file in a folder. It takes a different approach and I have never tried it, but for your reference: http://www.vbaexpress.com/kb/getarticle.php?kb_id=45

这篇关于WORD 2010编辑标头和宏页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆