Article ID: 147316
Article Last Modified on 10/11/2006
' Make sure to call this procedure after assigning the new labels to the
' controls. This Sub Procedure has two arguments: Ctrl is the control
' and NumToBlank is the number of spaces necessary to cover up the
' longest possible caption for the control.
Sub ClearLabels(Ctrl as Object, NumToBlank as Integer)
' Follow the current label with a lot of spaces.
Ctrl.Caption = Ctrl.Caption & _
String(NumToBlank - Len(Ctrl.Caption), " ")
End Sub
To call this procedure within a Visual Basic for Applications module and
have it apply to an option button named "Option1" (without the quotation
marks) on the Active Dialog, and to pad the label with 30 spaces, include a
call in the procedure that writes the labels as follows:
ClearLabels ActiveDialog.OptionButtons("Option1"), 30
Keep in mind that with proportional fonts, it may take more than 10 spaces
to obscure 10 wider characters (such as the "#" character). Also keep in
mind that the ClearLabels procedure must be called after making the
assignment of the new label caption.
' Make sure to call this after assigning the new labels to the controls.
Sub Clear_Labels()
' Dimension a variable to hold the objects.
Dim Control As Object
' Sets up a loop to run through every option button in the active
' dialog. Change ".OptionButtons" to ".CheckBoxes" if working with
' check boxes.
For Each Control In ActiveDialog.OptionButtons
' Set the caption equal to itself with 35 spaces after it.
' You may need to edit this line to increase or decrease the
' number of characters in the final label. Keep in mind that
' with proportional fonts, it may take more than 10 spaces to
' cover up 10 other characters.
Control.Caption = Control.Caption & _
String(35 - Len(Control.Caption), " ")
' Loop through the code.
Next Control
End Sub
Additional query words: 5.00a CheckBoxes Check Boxes Mac XL5 MXL5
Keywords: kbbug kbcode kbpending kbprogramming KB147316