React to Font-Changed Events

Use WithEvents to perform an action when you change any font properties of a specific control or form. Make sure you set the OLE Automation reference in the References dialog:

 ' Declaration sectionPrivate WithEvents fntAny As StdFontPrivate Sub fntAny_FontChanged(ByVal _	PropertyName As String)	Select Case PropertyName		Case "Name"			' Perform specific action		Case "Size"			' Perform specific action		Case "Italic"			' Perform specific action		Case "Bold"			' Perform specific action		Case "Underline"			' Perform specific action		'...		'...		' Similarly, you can extend the		' functionality for each font property.	End SelectEnd Sub

You only have to assign any form or control’s Font reference to fntAny. For example, if you want to trap the changes in the form’s font attributes, add this code to the Form_Load event:

 Set fntAny = Me.Font' If a control, then Control.Font
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: