none
How to hide a Frame Control in an imported Form Region for outlook addin RRS feed

  • Question

  • I am trying to convert a VBA to an addin. The form region designed in Outlook 2010 was successfully ported to a VB Outlook addin. Everything works except for a number of command buttons grouped into a Frame Control. In VBA I can just set frame.visible property using another Command Button to show and hide this Frame.

    How do one do that in form region? A number of articles seem to suggest that one can expose this visible property and other properties. I tried Globals, Microsoft.vbe.interops.Forms and several iteration but to no satisfactory results.

    Thank you

     

    Reference articles

    http://msdn.microsoft.com/en-us/library/bb772084%28v=vs.90%29.aspx

    http://msdn.microsoft.com/en-us/library/bhczd18c%28v=vs.90%29.aspx

    http://msdn.microsoft.com/en-us/library/43s90322%28v=vs.90%29.aspx

    Thursday, May 26, 2011 4:15 PM

Answers

  • I found the solution, seem like I was barking up the wrong tree. I had been trying to locate the Frame control from inside the Visual Studio which doesn't give me the properties I want. After reading through Ryan Gregg and Randy Byrne book "Programming Applications for Microsoft Office Outlook 2007", I stumbled onto my error.

    I should be trying to locate the control object instead.

    Scenerio: I have 6 olk CommandButtons inside a Frame control and using code to hide or show the frame control (and hence the 6 CommandButtons underneath). Because olk are outlook controls, Frame is MS Form 2.0 control, it does not work as per visual studio controls (ie .NET controls?).

    When the these controls are designed into a form region in outlook form designer, and imported into a visual studio project, the properties became private and cannot be seen by the vb codes.

    Using VSTO insiide Visual Studio, the Outlook add in template returns a me.OutlookFormRegion which points to the Form Region

    Solution: Cast the frame control to expose these properties by putting these codes inside the FormRegionShowing

     

    My solution: For Visual Basic Outlook addin,

    Private Sub FormRegion3_FormRegionShowing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.FormRegionShowing

            Dim Myform As Microsoft.Vbe.Interop.Forms.UserForm
            Dim m_FrameResponses As Microsoft.Vbe.Interop.Forms.Control

            Myform = Me.OutlookFormRegion.Form
            m_FrameResponses = Myform.Controls.Item("FrameResponses")

           'This hide the frame with the 6 commandbuttons on startup of the Form region
            m_FrameResponses.Visible = False

    End Sub

    • Marked as answer by Ideasmiths Friday, May 27, 2011 11:16 AM
    Friday, May 27, 2011 5:34 AM

All replies

  • If I understand what you’re asking, maybe something like this?

            Dim ctrl As Control

            For Each ctrl In Me.GroupBox6.Controls

                ctrl.Visible = False

            Next


    Kind Regards, Rich ... http://greatcirclelearning.com
    Thursday, May 26, 2011 5:39 PM
  • Thanks for the quick reply Rich. Not really what I was looking for. My apology for the lack of terminology as I just started with VSTO and addin.

    The routine you mentioned works on controls designed in the Visual Designer inside Visual Studio, but it wouldn't work on controls, either Form 2.0 or outlook controls (olk) designed in Outlook Form Designer then imported as Form region into the Visual Studio project. Visual Studio just don't 'see' these properties such as visible, focus, height, width etc (as mentioned in references in my starting thread)

    I need to make Visual Studio expose the properties such as visible and focus for MS Form 2.0 controls such Frame and _DocSiteControl. These controls were used by myself in Customising Outlook Form Pages and programmed using VBScript and VBA.

    From the Microsoft references above, it seem like one can add these properties in the form region code, then access it, but I have been banging my head against a hard walls for days and can't get anything to work.

    Thank you

    Friday, May 27, 2011 2:09 AM
  • I found the solution, seem like I was barking up the wrong tree. I had been trying to locate the Frame control from inside the Visual Studio which doesn't give me the properties I want. After reading through Ryan Gregg and Randy Byrne book "Programming Applications for Microsoft Office Outlook 2007", I stumbled onto my error.

    I should be trying to locate the control object instead.

    Scenerio: I have 6 olk CommandButtons inside a Frame control and using code to hide or show the frame control (and hence the 6 CommandButtons underneath). Because olk are outlook controls, Frame is MS Form 2.0 control, it does not work as per visual studio controls (ie .NET controls?).

    When the these controls are designed into a form region in outlook form designer, and imported into a visual studio project, the properties became private and cannot be seen by the vb codes.

    Using VSTO insiide Visual Studio, the Outlook add in template returns a me.OutlookFormRegion which points to the Form Region

    Solution: Cast the frame control to expose these properties by putting these codes inside the FormRegionShowing

     

    My solution: For Visual Basic Outlook addin,

    Private Sub FormRegion3_FormRegionShowing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.FormRegionShowing

            Dim Myform As Microsoft.Vbe.Interop.Forms.UserForm
            Dim m_FrameResponses As Microsoft.Vbe.Interop.Forms.Control

            Myform = Me.OutlookFormRegion.Form
            m_FrameResponses = Myform.Controls.Item("FrameResponses")

           'This hide the frame with the 6 commandbuttons on startup of the Form region
            m_FrameResponses.Visible = False

    End Sub

    • Marked as answer by Ideasmiths Friday, May 27, 2011 11:16 AM
    Friday, May 27, 2011 5:34 AM