gpt4 book ai didi

vba - 如何编写 Visio 宏以将形状从一层移动到另一层?

转载 作者:行者123 更新时间:2023-12-01 20:06:33 40 4
gpt4 key购买 nike

我正在使用 Visio 2003,我想编写一个宏,将所选项目移动到名为“已删除项目”的隐藏层。

我尝试录制宏,但得到的只是这个,它甚至没有向我展示如何与图层交互。 :(

Sub Move_to_Delete_Layer()
'
' Moves the selected item(s) to the "zDeleted Items" Layer (which typically remains hidden). This is basically an "undo-able" way to delete the item.
'
' Keyboard Shortcut: Ctrl+d
'

Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Layer")
Application.ActiveWindow.Page.Shapes.ItemFromID(175).CellsSRC(visSectionObject, visRowLayerMem, visLayerMember).FormulaU = """9"""
Application.EndUndoScope UndoScopeID1, True

End Sub

编辑:

谢谢。 SDK 有一点帮助,但不幸的是不足以生成工作代码。我认为我想做的本质上是

Dim myLayer As Visio.Layer
Set myLayer = Application.ActiveWindow.Page.Layers.Add("Deleted Items")
myLayer.Add Application.ActiveWindow.Selection.ContainingShape, 1

但是该代码不起作用。它给我一个错误,显示“运行时错误'-2032465766 (86db089a)':请求的操作目前已禁用”

我还想从它已经存在的任何图层中删除该形状。我不知道该怎么做。

最佳答案

VBA 中的图层非常简单:这将从页面中删除所有图层成员资格:

dim i as integer
for i = ShpObj.LayerCount to 1 Step -1
dim Lay as Visio.Layer
set Lay = ShpObj.Layer(i)
Lay.Remove ShpObj
next

这将为您的删除图层添加一个形状

Dim myLayer As Visio.Layer
Set myLayer = Application.ActiveWindow.Page.Layers.Add("Deleted Items")
myLayer.Add Application.ActiveWindow.Selection(1), 1

关于vba - 如何编写 Visio 宏以将形状从一层移动到另一层?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19283978/

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