在Visio中查找工作流对象3D

发布于 2025-02-10 03:52:21 字数 713 浏览 4 评论 0原文

我正在尝试在VBA Excel中创建一个代码,以检测工作流对象中的内容-3D如下图所示:

“在此处输入图像描述”

图片始终相同。我已经能够找到并选择单元格内部的句子。但是我需要它在不同的visio中搜索所有工作流对象。

这是我要的地方: DIM图表服务作为整数 DibargramServices = ActivedOcument.diagramServicesEnabled ActivedOcument.diagramServicesEnabled = visserviceversion140 + visserviceversion150

    Dim vsoCharacters1 As Visio.Characters
    Set vsoCharacters1 = Application.ActiveWindow.Page.Shapes.ItemFromID(228).Characters
    Debug.Print vsoCharacters1

我需要代码才能首先在Visio中的不同页面中查找所有工作流对象,然后在(vsocharacters1)中获取句子。

I´m trying to create a code in vba excel to detect what´s inside the work flow objects - 3D as the ones shown in the following picture:

enter image description here

The pictures are always the same. I have been able to find and select the sentence inside the cell. But I need it to search for all the work flow objects in different visio.

This is where I got to:
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Dim vsoCharacters1 As Visio.Characters
    Set vsoCharacters1 = Application.ActiveWindow.Page.Shapes.ItemFromID(228).Characters
    Debug.Print vsoCharacters1

I need the code to first find all the work flow objects in different pages in visio and then obtain the sentence within (vsoCharacters1)

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

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

发布评论

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

评论(2

给妤﹃绝世温柔 2025-02-17 03:52:21

请尝试此简单代码

Sub ttt()
Dim doc As Document ' Variable for Document
Dim pg As Page ' Variable for Page
Dim shp As Shape ' Variable for Shape
Dim txt As String  ' Variable for Shape's text
For Each doc In Documents ' Iterate all documents in Visio application session
    For Each pg In doc.Pages ' Iterate all pages in 'doc'
        For Each shp In pg.Shapes ' Iterate all docunents in 'pg'
            txt = shp.Text ' Define 'txt' variable
            Select Case txt ' Criterion
            Case "ololo", "trololo" ' Found text
                ActiveWindow.Page = pg ' Activate page with criterion
                ActiveWindow.Select shp, visSelect ' Select shape with criterion
                MsgBox "Page: " & pg.Name & ", ShapeID: " & shp.ID, , "A shape was found, the text of which matches the criterion: " & txt
            End Select
            ActiveWindow.DeselectAll ' Unselect a shape
        Next shp
    Next pg
Next doc
MsgBox "TheEnd!!!"
End Sub

注:
该代码始于MS Visio,无递归的代码,找不到分组的形状!

Please try this simple code

Sub ttt()
Dim doc As Document ' Variable for Document
Dim pg As Page ' Variable for Page
Dim shp As Shape ' Variable for Shape
Dim txt As String  ' Variable for Shape's text
For Each doc In Documents ' Iterate all documents in Visio application session
    For Each pg In doc.Pages ' Iterate all pages in 'doc'
        For Each shp In pg.Shapes ' Iterate all docunents in 'pg'
            txt = shp.Text ' Define 'txt' variable
            Select Case txt ' Criterion
            Case "ololo", "trololo" ' Found text
                ActiveWindow.Page = pg ' Activate page with criterion
                ActiveWindow.Select shp, visSelect ' Select shape with criterion
                MsgBox "Page: " & pg.Name & ", ShapeID: " & shp.ID, , "A shape was found, the text of which matches the criterion: " & txt
            End Select
            ActiveWindow.DeselectAll ' Unselect a shape
        Next shp
    Next pg
Next doc
MsgBox "TheEnd!!!"
End Sub

Note:
This code started in MS Visio, code without recursion, dont find shapes into groups !

萌吟 2025-02-17 03:52:21

我可以提出一种更系统的方法吗?

  1. 绘制资源管理器
  • 确保您处于开发人员模式。
  • 打开绘图资源管理器。
  1. 识别探索探索树木的形状,
  2. 以查看其子形状,

如果您幸运的话,专业人士已经制作了这种形状,并将其命名为子形状,例如标签,框架等。这将简化对此形状的访问。

在VBA中:

  • SHP为您的组形状对象
  • 访问子形状通过:SET SUBSHP = SHP.SHAPES(name_of_subshape)

这也适用于子形状的子形状。

否则 - 子形状被命名为表。234-您需要找到另一种标识方法。

  • 打开子形状(右鼠标键单击)的塑形表
  • 检查它,并尝试弄清楚它与其他子形状的差异。那可以是文本,用户或道具字段,几何部分...等。
  • 在VBA中,您将在所有子形状上循环并检查此属性。

例如:

for each subshape in shp.Shapes:
  if subshape.CellExists("soAndSo",0) then
   if subshape.Cells("soAndso").ResultStr("") = "thisAndThat" then
     'you found it, do your stuff.

顺便说一句,您无需访问形状的字符对象即可获取其文本。它只是“ shp.text”。字符对象更加复杂,可以让您用文本做有趣的事情。

May I propose a more systematic approach?

  1. Drawing explorer
  • Make sure you're in developer mode.
  • Switch the drawing explorer on.
  1. Identify the shape to explore
  2. Expand its tree to see its sub-shapes

If you're lucky a pro has made this shape and named the subshapes eg Label, Frame, what ever. This will simplify the access to this shape.

in VBA:

  • shp being your group shape object
  • access the sub-shape via: set subshp = shp.Shapes(name_of_subshape)

This works also for the sub-shapes of the sub-shape.

Otherwise - the sub-shapes are named sheet.234 - you need to find another identification method.

  • Open the shapesheet of the sub-shape (right-mouse-click)
  • Inspect it and try to figure out in how far it differs from the other sub-shapes. That can be a text, user or prop field, a geometry section ... etc.
  • in VBA you would then loop over all the sub-shapes and check for this property.

eg:

for each subshape in shp.Shapes:
  if subshape.CellExists("soAndSo",0) then
   if subshape.Cells("soAndso").ResultStr("") = "thisAndThat" then
     'you found it, do your stuff.

By the way, you don't need to access the characters object of a shape to get its text. It is simply "shp.Text". The characters object is more complexe and lets you do funny stuff with the text.

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