检查 Visio Shape.Cell 集合

发布于 2024-10-21 21:54:47 字数 129 浏览 1 评论 0原文

我需要一些关于如何在 vb 或 vba 中查询 VISIO Shape.cells 集合的建议。

我编写了一个应用程序来将形状拖放到页面上,并且可以在将其拖放到页面上后更改其名称。现在我想检查形状细胞集合。

谢谢

I need some suggestion on how to query a VISIO Shape.cells collection in vb or vba.

I have written an application to drop a shape on a page and I can change its name after dropping it on the page. Now I want to examine the shape cells collection.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少钕鈤記 2024-10-28 21:54:47

Visio 形状单元被分成不同的部分。此类部分可能包括用户单元格、操作或角色设置。还有一系列命名单元格,您只能(我认为)通过名称(即 PinX 或 PinY)访问。

因此,要查询形状的单元格,您首先必须弄清楚您正在谈论的单元格的哪个部分。要循环遍历单元格部分,首先获取该部分中的行数,然后使用形状对象上的 CellsSRC 方法循环遍历该部分。

Dim TheShp As Visio.Shape
Set TheShp = ActiveWindow.Selection.Item(1)
Dim TheSec As Visio.Section
Dim TheCell As Visio.Cell
Set TheSec = TheShp.Section(visSectionUser)
Dim RowNum As Long
For RowNum = 0 To TheSec.Count - 1
    Set TheCell = TheShp.CellsSRC(visSectionUser, RowNum, 0)
    Debug.Print TheCell.Formula
    Debug.Print TheCell.Result(visNone)
Next CellNum

如果存在多种形状的大量单元格,则以这种方式循环可能会很慢。如果您需要访问大量单元格的公式或结果,Page 对象上有 GetFormulas 和 GetResults 方法,它们采用 SRC 值和形状 ID 数组,从而同时提取所有这些公式/结果。

Visio shape cells are broken up into different sections. Such sections might include User Cells, Actions, or Character settings. There are also a series of named cells that you can only (I think) access through the name (i.e. PinX or PinY).

So to query a shape's cells, you first have to figure out what section of cells you're talking about. To loop through a cell section, you first get the number of rows in the section, then loop through that section using the CellsSRC method on the shape object.

Dim TheShp As Visio.Shape
Set TheShp = ActiveWindow.Selection.Item(1)
Dim TheSec As Visio.Section
Dim TheCell As Visio.Cell
Set TheSec = TheShp.Section(visSectionUser)
Dim RowNum As Long
For RowNum = 0 To TheSec.Count - 1
    Set TheCell = TheShp.CellsSRC(visSectionUser, RowNum, 0)
    Debug.Print TheCell.Formula
    Debug.Print TheCell.Result(visNone)
Next CellNum

Looping in this way can be slow if there are a lot of cells in a lot of shapes. If you need to access the formulas or results of a large number of cells, there are GetFormulas and GetResults methods on the Page object that take arrays of SRC values and shape ID's that will pull all those Formulas/Results at the same time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文