我正试图找出一种方法来快速格式化一个或多个数据模型连接的切片器(列数,单元格宽度/高度,切片器宽度/高度等),通常在将它们添加到工作簿之后,但也要求。我一直试图弄清楚如何遍历<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标签,因为这似乎无关紧要。
答案 0 :(得分:1)
您根本不需要Selection
:
Dim slc As Slicer
Set slc = ActiveWorkbook.ActiveSlicer
If Not slc Is Nothing Then
' do stuff
End If