By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

Setting font size of text box in VBA

P: n/a
I want to be able to set the font size and font type for text in a text box
on a report using VBA. I wan't to be able to control it from a setting in a
table. The problem is that I don't know the syntax for setting either font
type or font size for a text box on a report. Does anyone know? Help.
Please!

dixie
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
ctlTextBox.Height = 1440 'size in twips: 1440 = 1 inch
ctlTextBox.Width = 2880 'size in twips: 1440 = 1 inch

'so you can see the area covered by the textbox
ctlTextBox.BackColor = RGB(255, 255, 0)

ctlTextBox.FontSize = 20
ctlTextBox.FontName = "Comic Sans MS"

changing the font size, name, bolding, means you may also need to change
the size of the textbox correspondingly. 1 inch is 1440 twips

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"dixie" <di****@dogmail.com> wrote in message
news:C0*****************@nnrp1.ozemail.com.au...
I want to be able to set the font size and font type for text in a text box on a report using VBA. I wan't to be able to control it from a setting in a table. The problem is that I don't know the syntax for setting either font type or font size for a text box on a report. Does anyone know? Help.
Please!

dixie

Nov 12 '05 #2

P: n/a
Dixie,
In the Report's Detail Format event:

If [SomeField] = "Something" Then
[SomeField].FontName = "Ariel"
[SomeControl].FontSize = "12"
Else
[SomeField].FontName = "Times New Roman"
[SomeControl].FontSize = "10"
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:C0*****************@nnrp1.ozemail.com.au...
I want to be able to set the font size and font type for text in a text box on a report using VBA. I wan't to be able to control it from a setting in a table. The problem is that I don't know the syntax for setting either font type or font size for a text box on a report. Does anyone know? Help.
Please!

dixie

Nov 12 '05 #3

P: n/a
Thankyou for that Fred. There isn't an equivalent type of setting for page
margins is there? I have looked at the width and height settings, but
nowhere can I find anything that would allow me to programatically set the
position of the left margin based on a value that could be placed in a
table. This would be quite useful.

dixie

"Fredg" <fg******@example.invalid> wrote in message
news:R2**********************@bgtnsc05-news.ops.worldnet.att.net...
Dixie,
In the Report's Detail Format event:

If [SomeField] = "Something" Then
[SomeField].FontName = "Ariel"
[SomeControl].FontSize = "12"
Else
[SomeField].FontName = "Times New Roman"
[SomeControl].FontSize = "10"
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:C0*****************@nnrp1.ozemail.com.au...
I want to be able to set the font size and font type for text in a text box
on a report using VBA. I wan't to be able to control it from a setting

in a
table. The problem is that I don't know the syntax for setting either

font
type or font size for a text box on a report. Does anyone know? Help.
Please!

dixie


Nov 12 '05 #4

P: n/a
Dixie,

It's hard to help as you haven't given enough information as to what you
expect to happen.
The below ** Air code ** should move each control 3/4" to the right if
[SomeControl] = "Something",
otherwise it will move all the controls 3/4" to the left (1440 Twips per
inch).
Place it in whatever format event the controls are in.
Place the leftmost control at least 3/4" from the left margin.
Place the right side of the rightmost control at least 3/4" from the right
margin.

Adapt this as needed.

Dim c as Control
For each c in controls
If [SomeField] = "Something" Then
c.left = c.left + (1440 * 0.75)
Else
c.left = c.left - (1440 * 0.75)
End If

To actually change the left margin, look up the PrtMips method in VBA help.
However, to use it, the report must be open in Design View, not during
runtime.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:Vx************@nnrp1.ozemail.com.au...
Thankyou for that Fred. There isn't an equivalent type of setting for page margins is there? I have looked at the width and height settings, but
nowhere can I find anything that would allow me to programatically set the
position of the left margin based on a value that could be placed in a
table. This would be quite useful.

dixie

"Fredg" <fg******@example.invalid> wrote in message
news:R2**********************@bgtnsc05-news.ops.worldnet.att.net...
Dixie,
In the Report's Detail Format event:

If [SomeField] = "Something" Then
[SomeField].FontName = "Ariel"
[SomeControl].FontSize = "12"
Else
[SomeField].FontName = "Times New Roman"
[SomeControl].FontSize = "10"
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:C0*****************@nnrp1.ozemail.com.au...
I want to be able to set the font size and font type for text in a text
box
on a report using VBA. I wan't to be able to control it from a
setting in
a
table. The problem is that I don't know the syntax for setting either

font
type or font size for a text box on a report. Does anyone know?

Help. Please!

dixie



Nov 12 '05 #5

P: n/a
That looks promising fred, I'll have a play with it. What I am actually
trying to achieve is to be able to move the address on a letter sideways so
it will fit into various sorts of windowed envelopes. Since the movement I
see is usually to the right, this will probably work OK.

Thanks
dixie

"Fredg" <fg******@example.invalid> wrote in message
news:e2**********************@bgtnsc05-news.ops.worldnet.att.net...
Dixie,

It's hard to help as you haven't given enough information as to what you
expect to happen.
The below ** Air code ** should move each control 3/4" to the right if
[SomeControl] = "Something",
otherwise it will move all the controls 3/4" to the left (1440 Twips per
inch).
Place it in whatever format event the controls are in.
Place the leftmost control at least 3/4" from the left margin.
Place the right side of the rightmost control at least 3/4" from the right
margin.

Adapt this as needed.

Dim c as Control
For each c in controls
If [SomeField] = "Something" Then
c.left = c.left + (1440 * 0.75)
Else
c.left = c.left - (1440 * 0.75)
End If

To actually change the left margin, look up the PrtMips method in VBA help. However, to use it, the report must be open in Design View, not during
runtime.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:Vx************@nnrp1.ozemail.com.au...
Thankyou for that Fred. There isn't an equivalent type of setting for

page
margins is there? I have looked at the width and height settings, but
nowhere can I find anything that would allow me to programatically set the
position of the left margin based on a value that could be placed in a
table. This would be quite useful.

dixie

"Fredg" <fg******@example.invalid> wrote in message
news:R2**********************@bgtnsc05-news.ops.worldnet.att.net...
Dixie,
In the Report's Detail Format event:

If [SomeField] = "Something" Then
[SomeField].FontName = "Ariel"
[SomeControl].FontSize = "12"
Else
[SomeField].FontName = "Times New Roman"
[SomeControl].FontSize = "10"
End If

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"dixie" <di****@dogmail.com> wrote in message
news:C0*****************@nnrp1.ozemail.com.au...
> I want to be able to set the font size and font type for text in a

text box
> on a report using VBA. I wan't to be able to control it from a setting
in
a
> table. The problem is that I don't know the syntax for setting either font
> type or font size for a text box on a report. Does anyone know?

Help. > Please!
>
> dixie
>
>



Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.