VBA to open an embedded Excel Object

Discussion in 'Visio' started by gthomas, May 6, 2014.

  1. gthomas

    gthomas

    Joined:
    May 6, 2014
    Messages:
    1
    Likes Received:
    0
    I have created a group where one of the shapes in the group is an embedded Excel workbook (Sheet.5 in my example below).

    I would like the double-click behavior of the group to be opening up the spreadsheet for editing.

    I have assigned a macro to the group double-click via the Format/Behaviour dialog.

    My question is why does this always work:
    ----------
    Code:
    Sub EditVolumeSheet()
        Dim shpTheShape As Visio.Shape
        Set shpTheShape = ActivePage.Shapes("Sheet.5")
        ActiveWindow.Select shpTheShape, visSubSelect
        On Error Resume Next
        Application.DoCmd visCmdEditOpenObject
        Application.DoCmd visCmdEditOpenObject
    End Sub
    --------

    But this only works if the group or a sub-shape in the group was selected just before I double-click:
    --------------
    Code:
    Sub EditVolumeSheet()
        Dim shpTheShape As Visio.Shape
        Set shpTheShape = ActivePage.Shapes("Sheet.5")
        ActiveWindow.Select shpTheShape, visSubSelect
        Application.DoCmd visCmdEditOpenObject
    End Sub
    -----------------
     
    gthomas, May 6, 2014
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.