gpt4 book ai didi

excel - VB.Net:在某个单元格中插入形状

转载 作者:行者123 更新时间:2023-12-04 21:22:32 24 4
gpt4 key购买 nike

我正在尝试在特定单元格中插入一个形状,例如 (5,5)。我能够将形状放入 excel 中,但不知道如何将其放入 (5,5) 中。经过研究,我知道形状位于工作表中的单元格顶部。我还了解到.Range在这里可能会有所帮助。

我只是不确定如何将这些拼图拼凑在一起以使我的形状变为(5,5)。
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle, 17, 0, 15, 13)
另外,我是 vb.net 的初学者,所以如果你能把所有东西都搞砸,我会非常感激的!

编辑:
试过这个代码..但它把数字 7在 (5,5) 而不是形状。
Dim aNew As MsoAutoShapeType = MsoAutoShapeType.msoShapeIsoscelesTriangle
xlWorkSheet.Cells(5, 5) = anew

也试过:
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Left, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Top, 15, 13)

但收到一个错误
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred
编辑:有效的代码......
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, (xlWorkSheet.Cells(3, 5)).Left, (xlWorkSheet.Cells(3, 5)).Top, 25, 14)

最佳答案

类似的东西xlWorkSheet.get_range(xlWorkSheet.cells(5.5)).topcells(5.5).top
发生“System.Runtime.InteropServices.COMException”类型的未处理异常

调试,使用 xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Top分解它,所以,是xlWorkSheet好的,是 xlWorkSheet.Cells(5, 5)好的,是 xlWorkSheet.Range(xlWorkSheet.Cells(5, 5))好的,错误在哪里,分解大语句,实际上从它们的组成部分开始,然后查看它们的返回并像您在此处所做的那样链接在一起xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscel‌​esTriangle, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Left, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Top, 15, 13)我们看不到您的代码/屏幕

关于excel - VB.Net:在某个单元格中插入形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41105467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com