Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 更改SmartArtNodes的宽度或高度_Vba_Excel - Fatal编程技术网

Vba 更改SmartArtNodes的宽度或高度

Vba 更改SmartArtNodes的宽度或高度,vba,excel,Vba,Excel,是否可以更改SmartArtNode的宽度或高度 以下代码根本不起作用: ' mySmartArt is a SmartArt Object mySmartArt.AllNodes.Item(1).Shapes.Width = 4 奇怪的是,如果你改变一个形状的宽度,它就会起作用。所以我不知道为什么SmartArtNodes的形状对象根本无法调整大小。我知道的唯一方法是使用较大或较小的方法,但使用此方法不可能仅更改形状的宽度/高度 如果我使用上面的代码,我总是会得到一个运行时错误“Object

是否可以更改SmartArtNode的宽度或高度

以下代码根本不起作用:

' mySmartArt is a SmartArt Object
mySmartArt.AllNodes.Item(1).Shapes.Width = 4
奇怪的是,如果你改变一个形状的宽度,它就会起作用。所以我不知道为什么SmartArtNodes的形状对象根本无法调整大小。我知道的唯一方法是使用较大或较小的方法,但使用此方法不可能仅更改形状的宽度/高度

如果我使用上面的代码,我总是会得到一个运行时错误“Object不支持此操作(错误445)”,这很奇怪,因为通过Excel的GUI,我可以毫无问题地更改SmartArt单个节点的宽度和高度。因此,为什么不可能通过VBA更改它,这是毫无意义的

有人知道我如何解决这个问题吗?

像这样

Sub Macro1()

Dim Sma As Shape
Set Sma = ActiveSheet.Shapes.AddSmartArt(Application.SmartArtLayouts(2))

With Sma
    .ScaleHeight 1.5, msoFalse, msoScaleFromBottomRight
    .ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
End With

End Sub

5月4日19:23发布。他似乎在使用布局,我不知道这是否适用于您,但它似乎很有趣,值得一看!;)也许可以尝试mysmart.AllNodes.Item(1).Shapes.Item(1).Width?@mysmart.AllNodes.Item(1).Shapes.Item(1).Width也不起作用;如果形状是SmartArtNode,则似乎无法更改其宽度或高度;唯一有意思的是,在Excel中,您可以更改宽度和高度,所以VBA似乎无法做到这一点that@R3uK他/她只是在改变SmartArt本身的高度和宽度,而不是单个节点的高度和宽度。对于我迟来的响应,他/她表示抱歉。但是,您的代码只会更改整个SmartArt的大小。我还尝试对其进行调整,使其仅适用于SmartArtNodes,但这也不起作用。