问题描述
我正在尝试编写一个宏,该宏可以查看工作表保留的水平分页符列表,看来HPageBreaks应该就是这样.我可以从中添加或删除分页符,但似乎无法隔离集合本身来查看其内容.甚至添加手表并查看ActiveSheet.HPageBreaks都只会显示一个计数字段等于0的通用外观对象,而与现有分页符无关.
I'm trying to write a macro which can look into the list of horizontal page breaks that a worksheet keeps, and it seems like HPageBreaks should be exactly that. I can add or remove page breaks from it, but I can't seem to isolate the collection itself to look at its contents. Even adding a watch and looking at ActiveSheet.HPageBreaks just brings up a generic looking object with a count field equal to 0 regardless of existing page breaks.
我现在对此感到非常困惑.有什么办法可以查看工作表中现有的分页符吗?列出行在行之间/行之间的行会很不错.
I'm really confused about this now. Is there any way to look into the existing page breaks within a sheet? A listing of what rows they occur on/between would be great.
推荐答案
这应该使您入门:
Sub testing()
MsgBox "There are " & ActiveSheet.HPageBreaks.Count & " pagebreaks."
For Each pb In ActiveSheet.HPageBreaks
MsgBox "a page break lies between rows " & pb.Location.Row - 1 _
& " and " & pb.Location.Row
Next
End Sub
这里有一些(相当少)参考.:
Here are some (rather scanty) references.:
http://msdn.microsoft.com/zh-cn/library/aa661442(office.10).aspx
http://msdn.microsoft.com/zh-cn/library/aa206426(office.10).aspx
这篇关于Excel 2007 VBA:如何引用HPageBreaks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!