为所选形状选择visio形状并运行加载项

时间:2015-05-08 18:12:02

标签: vb.net ms-office add-in visio

我使用vb.net创建了一个visio加载项。单击该加载项时,会显示一个表单,用于插入所选形状的形状数据行。

过程:

在页面上删除形状>>选择形状(如果未选择)>>点击加载项按钮>> Windows窗体显示

当我放下第一个形状时,这非常有效。但是当我从同一个母版中删除另一个形状并单击加载项按钮时,表单不会显示。

我有这个代码:

Dim xPS as Visio.Shape
xPS = Globals.ThisAddIn.Application.ActiveWindow.Selection.PrimaryItem

    If xPS Is Nothing Then
        MsgBox("ERROR: " & vbCrLf & "No 'AA' shape selected. Please select an 'AA' shape and rerun the command")
        Exit Sub
    Else
        'If a shape other than 'AA' is selected, a message box is displayed with error description.
        If Left(xPS.Name, 2) <> "AA" Then
            MsgBox("ERROR: " & vbCrLf & "Incorrect shape selected." & vbCrLf & "Please select 'AA' shape and rerun the command.")
            Exit Sub
        Else
             xCT.Show()          'Shows the user form
        End If
   End If

我怀疑我没有使用所选形状的正确语法。

xPS = Globals.ThisAddIn.Application.ActiveWindow.Selection.PrimaryItem

有人可以告诉我为什么表格没有显示第二个形状,但是第一个形状呢?

感谢您的帮助。

三木

0 个答案:

没有答案