requested operation is currently disabled

Started by perry59, February 28, 2017, 08:59:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I am trying to do something that I though would be pretty simple, just drop a couple shapes on a page, group them and select the group.
I borrowed some vba code (which works in vba) and put it in my vb.net addin but get the error message "requested operation is currently disabled" on the last line shown here.
can anybody tell me what I'm doing wrong?


Private Sub DropButton_Click(sender As Object, e As EventArgs) Handles DropButton.Click
        Dim CurrentPage As Microsoft.Office.Interop.Visio.Page
        Dim MasterName As String = String.Empty
        Dim StencilName As String = String.Empty
        Dim pinX As Integer = 0
        Dim pinY As Integer = 0
        Dim units As Object = Nothing
        Dim newShape As Microsoft.Office.Interop.Visio.Shape

        Dim groupShape As Microsoft.Office.Interop.Visio.Shape
        Dim selection As Microsoft.Office.Interop.Visio.Selection
        Dim subShape As Microsoft.Office.Interop.Visio.Shape
        Dim Shape2 As Microsoft.Office.Interop.Visio.Shape

        CurrentPage = Globals.ThisAddIn.Application.ActivePage
        MasterName = "Connector"
        StencilName = "Wiring.vss"
        pinX = -6
        pinY = -6

        Dim currentWindow As Microsoft.Office.Interop.Visio.Window
        currentWindow = Globals.ThisAddIn.Application.ActiveWindow
        'Dim mouseEvents As New HandleMouseEvents(currentWindow)
        mouseHandler = New HandleMouseEvents(currentWindow)


        'Drop a shape on the page.
        newShape = DropMasterOnPage(CurrentPage, MasterName, StencilName, pinX, pinY, units)
        'Make sure only one shape is selected to start.
        selection = Globals.ThisAddIn.Application.ActiveWindow.Selection
        selection.Select(newShape, VisSelectArgs.visDeselectAll + VisSelectArgs.visSelect)

        'Create a group shape.
        groupShape = selection.Group    'Requested operation Is presently disabled
what, me worry?

perry59

Nevermind.
I was under the mistaken impression you could initially do a group with just one shape and add to it later.
what, me worry?

wapperdude

You can convert a single shape into a group.  Not sure how with vba.  Macro recorder would give the code.  Then you can add other shapes to the group.  But, you could not delete that first shape from the group for obvious reasons.

Wapperdude
Visio 2019 Pro

wapperdude

BTW, check your drop master post.

Wapperdude
Visio 2019 Pro

perry59

Well, it seems the problem was that the shape I was trying to group already WAS a group.
So after dropping it, I just got rid of the selection code and was able to drop other shapes into the existing group.
what, me worry?

perry59

Quote from: wapperdude on March 01, 2017, 12:51:55 AM
BTW, check your drop master post.

Wapperdude

yes, I did see your post on "drawrect". I could have swore that it was Microsofts own page that told me it was for visio 2010 and above.
what, me worry?