简体   繁体   English

excel 2007 vba:如何引用HPageBreaks

[英]excel 2007 vba: how to refer to HPageBreaks

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. 我正在尝试编写一个宏,它可以查看工作表保留的水平分页符列表,看起来HPageBreaks应该就是这样。 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. 即使添加一个手表并查看ActiveSheet.HPageBreaks,也只会显示一个通用外观对象,其count字段等于0,而不管现有的分页符。

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. 它们在/之间出现的行的列表将是很好的。

This should get you started: 这应该让你开始:

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/en-us/library/aa661442(office.10).aspx http://msdn.microsoft.com/en-us/library/aa661442(office.10).aspx

http://msdn.microsoft.com/en-us/library/aa206426(office.10).aspx http://msdn.microsoft.com/en-us/library/aa206426(office.10).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM