选定的切片机

时间:2016-01-22 01:40:05

标签: excel-vba excel-2013 vba excel

我正试图找出一种方法来快速格式化一个或多个数据模型连接的切片器(列数,单元格宽度/高度,切片器宽度/高度等),通常在将它们添加到工作簿之后,但也要求。我一直试图弄清楚如何遍历<doctype html> <html> <head></head> <body> <table> <thead></thead> <tbody id='add-to'></tbody> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> // holds all the buttons Id's so I can keep track of which button I pressed var id_hold = [] $(document).ready(function() { for (var i = 0; i < id_hold; i++) { // should add print something to the console if any button is clicked $('#' + id_hold[i]).click(function() { console.log('clicked button ' + i); }); } addIds(); }); function addIds() { // allows me to add things to the table I made above var add_to_dom = $('#add-to'); for (var i = 0; i < 10; i++) { add_to_dom.append('<button id =' + i + '></button>'); } } } </script> </body> </html>对象层次结构,但我似乎无法弄清楚如何从Selection我从Object/Rectangle对象转到选定的Selection对象。

我看到我可以很容易地走另一条路,就像我可以使用Slicer

直接从Shape访问Slicer对象一样

我唯一的选择是迭代所有ActiveWorkbook.SlicerCaches("Slicer_Test1").Slicers("Test").Shape中的所有Slicers,直到我匹配与SlicerCaches同名的Shape(或者匹配多个名称,如果我选择了多个切片机?)

这有什么意义吗?我认为这应该更容易理解,但我正在试图研究它。

感谢您提供的任何指示!

编辑:删除了powerpivot标签,因为这似乎无关紧要。

1 个答案:

答案 0 :(得分:1)

您根本不需要Selection

Dim slc                   As Slicer
Set slc = ActiveWorkbook.ActiveSlicer
If Not slc Is Nothing Then
    ' do stuff
End If
相关问题