Connecting Tech Pros Worldwide Forums | Help | Site Map

Setting font size of text box in VBA

dixie
Guest
 
Posts: n/a
#1: Nov 12 '05
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



xzzy
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Setting font size of text box in VBA


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" <dixiec@dogmail.com> wrote in message
news:C0%Jb.968$FD6.34284@nnrp1.ozemail.com.au...[color=blue]
> I want to be able to set the font size and font type for text in a text[/color]
box[color=blue]
> on a report using VBA. I wan't to be able to control it from a setting in[/color]
a[color=blue]
> table. The problem is that I don't know the syntax for setting either[/color]
font[color=blue]
> type or font size for a text box on a report. Does anyone know? Help.
> Please!
>
> dixie
>
>[/color]


Fredg
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Setting font size of text box in VBA


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" <dixiec@dogmail.com> wrote in message
news:C0%Jb.968$FD6.34284@nnrp1.ozemail.com.au...[color=blue]
> I want to be able to set the font size and font type for text in a text[/color]
box[color=blue]
> on a report using VBA. I wan't to be able to control it from a setting in[/color]
a[color=blue]
> table. The problem is that I don't know the syntax for setting either[/color]
font[color=blue]
> type or font size for a text box on a report. Does anyone know? Help.
> Please!
>
> dixie
>
>[/color]


dixie
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Setting font size of text box in VBA


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" <fgutkind@example.invalid> wrote in message
news:R20Kb.280323$Ec1.9624382@bgtnsc05-news.ops.worldnet.att.net...[color=blue]
> 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" <dixiec@dogmail.com> wrote in message
> news:C0%Jb.968$FD6.34284@nnrp1.ozemail.com.au...[color=green]
> > I want to be able to set the font size and font type for text in a text[/color]
> box[color=green]
> > on a report using VBA. I wan't to be able to control it from a setting[/color][/color]
in[color=blue]
> a[color=green]
> > table. The problem is that I don't know the syntax for setting either[/color]
> font[color=green]
> > type or font size for a text box on a report. Does anyone know? Help.
> > Please!
> >
> > dixie
> >
> >[/color]
>
>[/color]


Fredg
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Setting font size of text box in VBA


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" <dixiec@dogmail.com> wrote in message
news:VxlKb.5$8p.647@nnrp1.ozemail.com.au...[color=blue]
> Thankyou for that Fred. There isn't an equivalent type of setting for[/color]
page[color=blue]
> 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" <fgutkind@example.invalid> wrote in message
> news:R20Kb.280323$Ec1.9624382@bgtnsc05-news.ops.worldnet.att.net...[color=green]
> > 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" <dixiec@dogmail.com> wrote in message
> > news:C0%Jb.968$FD6.34284@nnrp1.ozemail.com.au...[color=darkred]
> > > I want to be able to set the font size and font type for text in a[/color][/color][/color]
text[color=blue][color=green]
> > box[color=darkred]
> > > on a report using VBA. I wan't to be able to control it from a[/color][/color][/color]
setting[color=blue]
> in[color=green]
> > a[color=darkred]
> > > table. The problem is that I don't know the syntax for setting either[/color]
> > font[color=darkred]
> > > type or font size for a text box on a report. Does anyone know?[/color][/color][/color]
Help.[color=blue][color=green][color=darkred]
> > > Please!
> > >
> > > dixie
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


dixie
Guest
 
Posts: n/a
#6: Nov 12 '05

re: Setting font size of text box in VBA


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" <fgutkind@example.invalid> wrote in message
news:e2mKb.284421$Ec1.9764322@bgtnsc05-news.ops.worldnet.att.net...[color=blue]
> 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[/color]
help.[color=blue]
> 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" <dixiec@dogmail.com> wrote in message
> news:VxlKb.5$8p.647@nnrp1.ozemail.com.au...[color=green]
> > Thankyou for that Fred. There isn't an equivalent type of setting for[/color]
> page[color=green]
> > 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[/color][/color]
the[color=blue][color=green]
> > position of the left margin based on a value that could be placed in a
> > table. This would be quite useful.
> >
> > dixie
> >
> > "Fredg" <fgutkind@example.invalid> wrote in message
> > news:R20Kb.280323$Ec1.9624382@bgtnsc05-news.ops.worldnet.att.net...[color=darkred]
> > > 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" <dixiec@dogmail.com> wrote in message
> > > news:C0%Jb.968$FD6.34284@nnrp1.ozemail.com.au...
> > > > I want to be able to set the font size and font type for text in a[/color][/color]
> text[color=green][color=darkred]
> > > box
> > > > on a report using VBA. I wan't to be able to control it from a[/color][/color]
> setting[color=green]
> > in[color=darkred]
> > > a
> > > > table. The problem is that I don't know the syntax for setting[/color][/color][/color]
either[color=blue][color=green][color=darkred]
> > > font
> > > > type or font size for a text box on a report. Does anyone know?[/color][/color]
> Help.[color=green][color=darkred]
> > > > Please!
> > > >
> > > > dixie
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes