MS AccessレポートのTextBoxの文字サイズを幅で自動調整する関数

Public Static Sub adjustFontSize(ByRef report As Report, ByRef textBox As TextBox)

Dim text As String
text = textBox.text

Report.FontSize = textBox.FontSize

Dim tempWidth As Integer
tempWidth = Report.TextWidth(text)

Do While textBox.Width < tempWidth Report.FontSize = Report.FontSize - 1 tempWidth = Report.TextWidth(text) Loop textBox.FontSize = Report.FontSize End Sub [/sourcecode]