none
Visio Callthis not working RRS feed

  • Question

  • Hi. Please somebody help me. 

    I'm a real beginner with VBA in Visio. 

    To practice, I've created following procedure in the module called, module1. 

    Public Sub Connection_mgmt(ByRef shpIn As Shape)
    Dim shp As Shape
    Dim shp_name As Variant
        
    shp_name = shpIn.Name

    MsgBox ("test")

    UserForm2.Show

    End Sub

    I just wanted to see if this procedure works when I double click a specific shape in the diagram. In ShapeSheet, this is what I did in "EventDblClick" cell, 

    =CALLTHIS("Connection_mgmt")

    However... when I double click the shape.. nothing happens..

    I have no idea what I need to go to test this procedure. Could someone please give me advice?

    Thank you so much in advance. 

    Wednesday, April 9, 2014 3:32 AM

Answers

  • I suspect it is not a visio problem, rather it is a vba coding issue. You have defined shp_name as a variant, which requires you to use a 'Set' to apply a value.

    to debug : put a stop at the subroutine and make sure it is being called (if not make sure your trust options are set correctly (trust vba, a trusted path, etc.), you can then use 'stops' to step through the routine to see if the  variables are acting correctly

    consider :

    dim shp_Name as visio.shape

    set shp_Name = shpIn

    dim strName as string

    strName = shpIn.nameU

    debug.print strName

    ' or

    debug.print shpIn.nameu

    ' or

    debug.print shp_name.nameu

    al edlund


    Al Edlund Visio MVP

    • Marked as answer by Marvin_Guo Wednesday, April 23, 2014 1:36 AM
    Monday, April 14, 2014 12:46 PM

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Visio, I'll move your question to the MSDN forum for Visio

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support

    Thursday, April 10, 2014 3:13 AM
  • Hi,

    Based on my understanding, you want to call VBA procedures from a ShapeSheet cell. you can test this procedures in Events.EventDblClick.

    1. Select the shape. Then, on the Window menu, click Show ShapeSheet.

    2. In the ShapeSheet window, find the EventDblClick cell in the Events section.

    3. In the EventDblClick cell, use the RUNMACRO to perform the Marcos function like below.

    EventDblClick = RUNMACRO("ThisDocument.TestFunction")   ' Marcos in ThisDocument

    Or

    EventDblClick = RUNMARCO("TestFunction ") ' Marcos in new module

    After setting the formula, simply double-click your shape, and you should see the message box!

    Regards

    Marvin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 14, 2014 9:29 AM
  • I suspect it is not a visio problem, rather it is a vba coding issue. You have defined shp_name as a variant, which requires you to use a 'Set' to apply a value.

    to debug : put a stop at the subroutine and make sure it is being called (if not make sure your trust options are set correctly (trust vba, a trusted path, etc.), you can then use 'stops' to step through the routine to see if the  variables are acting correctly

    consider :

    dim shp_Name as visio.shape

    set shp_Name = shpIn

    dim strName as string

    strName = shpIn.nameU

    debug.print strName

    ' or

    debug.print shpIn.nameu

    ' or

    debug.print shp_name.nameu

    al edlund


    Al Edlund Visio MVP

    • Marked as answer by Marvin_Guo Wednesday, April 23, 2014 1:36 AM
    Monday, April 14, 2014 12:46 PM