Resize a Control Horizontally and Vertically with the Form

The following code sample shows how to resize a control with a form. It uses the OlkControl class that represents some basic properties (for example, HorizontalLayout and ** VerticalLayout**) common to Outlook form controls. It assumes an existing Outlook text box control, myTextBox, in the form, and uses casting in Visual Basic to allow the text box control to use the properties of OlkControl.

Dim olkCtrl As Outlook.OlkControl

    ' Let the text box control use the properties of OlkControl
    Set olkCtrl = myTextBox
    
    ' Enable automatic adjustments of the layout with respect to the rest of the form
    olkCtrl.EnableAutoLayout = True

    ' Allow resizing the text box control horizontally and vertically with the form
    olkCtrl.HorizontalLayout = olHorizontalLayoutGrow
    olkCtrl.VerticalLayout = olVerticalLayoutGrow

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.