使用Visio VBA从多个形状表中删除形状

时间:2016-04-18 06:28:57

标签: vba visio

我希望能够使用VBA从不同的工作表中删除形状。我可以使用以下方法完成:

AppVisio.Documents.AddEx "basflo_u.vst", 0, 0
AppVisio.Documents.OpenEx "basic_u.vss", visOpenRO + visOpenDocked

Do

Set currentcell = Worksheets("sheet").Range("A1")

    box_type = currentcell.Offset(0, 1)

    Select Case box_type
        Case "Process", "Start/End", "Document", "Decision", "Subprocess"
            shape_sheet = "basflo_u.vss"
        Case "Ellipse", "Square", "Rectangle", "Circle"
            shape_sheet = "basic_u.vss"
        Case Else
            MsgBox "Invalid shape: " & box_type & " on line: " & currentcell.row
    End Select

    'Drop shape
    Set new_shape =  AppVisio.ActiveWindow.Page.Drop(AppVisio.Documents.Item(shape_sheet).Masters.ItemU(box_type), 2, 2)

Loop Until IsEmpty(currentcell.Offset(0, next_offset))

但这看起来很笨拙!我必须知道每个形状的形状表吗?有没有办法在不知道它的形状表的情况下放下形状?

使用Visio 2010 Standard

输入文件是:

Shape Text          Shape Type
Start               Start/End
Process 1           Process
If Something        Decision
Process 2           Process
Data                Ellipse   ' Note comes from different shape sheet basic_u.vss
Process 3           Process
If Something Else   Decision
Process 4           Subprocess
End                 Start/End

0 个答案:

没有答案
相关问题