Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox in VBA; font size 6

Status
Not open for further replies.

newguy86

Technical User
May 19, 2008
226
US
I have created a message box in my macro and it works perfectly fine. The only thing is that I am wanting to enlarge the font in the message box so it is easier to read. The help function in VBA is not very helpful on this topic. Any suggestions?

Travis
 
Message box fonts are set to the users preference in the OS settings. Do you realy want to override these?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
You can control it but only by using the windows messagebox rather than the Excel one - you will need an API call and it's quite a lot more code. Is it really that important?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Hi

I think better way to achive your requirment is, add a frame to your window and custimze it as you want. Add a close button and in onclick event hide that frame. In page load hide that frame and when ever you require it, show it.

Satyendra
 
My point still stands. The user has set thier prefrance should you change it?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Chris - Windows messagebox doesn't change any default settings...it just has a set of properties that the VBA messagebox doesn't have...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
So my next question is that; If I change the font size of the message box will it stay the same size or will it go back to the settings of the individual PC?

Travis
 
You change the size of the messagebox generated that is using the API call.

"will it go back to the settings of the individual PC"

Will WHAT go back?

If you generate a messagebox that is configured using API, then...it is generated. That one.

If you generate a messagebox that is not reconfigured using API...then it is generated without the API call.

faq219-2884

Gerry
My paintings and sculpture
 
What I was saying was will the font size go back to a default on another PC?

For example:
PC 1 is where the macro was created with the MsgBox. The font size for the MsgBox is changed on PC 1.

PC 2 is where another person uses the macro created on PC 1 to do whatever.

Will the font size be able to transfer from PC 1 to PC 2 so that the MsgBox will display at the same font sizes, and if so how? Or when PC 2 pulls up the macro to run it, will the MsgBox more than likely display the default size that is on PC 2?

Travis
 
You specify the font size as part of the code that pops up the message box. It is not SET anywhere. It is not CHANGED anywhere. The only difference is that this messagebox has a font property that can be set. The VBA one does not

To be honest though, the easiest way to do this is to create a little userform - that way you can put whatever controls you want on it and use whatever font size / colour you need

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Sorry I may have not clearly stated my point.

What I mean to say is that if a user has set their system fonts (and thus message box fonts) to their prefrence then this is no doubt because is a font (type and size) that they find easy to read.

Is it then good practice to write code that overrides these settings, even in a one off message?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
I have to agree with CluelessChris that one should not normally override user settings.

I would also point out that, as far as I know, you cannot, even with the API, use a different font size in a message box. You can, of course, use other techniques (e.g. userform) to easily display messages in any font you like - as posted by Geoff.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
ClulessChris:

Your point feels kind of like saying, "users have presumably set up their web browsers with a font they like. Should I really override it by using bold, [red]red[/red] or [!]bold red[/!] text to mark certain text as being particularly important?"

Granted, I don't think it would be very polite to make the font in a msgbox 2 inches high, but the standard VBA msgbox doesn't give you any control whatsoever over the formatting of the text.

Also, if most users in your office have "set their system fonts" to anything other than default, that's a much different environment than the one in which I work. [smile]

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Using API is possible, but complicated for people not used to using API. All this can be avoided by doing what Geoff suggested.

Make a userform. You can control just about everything, and it would be the same no matter who used it.

faq219-2884

Gerry
My paintings and sculpture
 
Ok now I see what you guys are saying. I will work on the userbox and see what I come up with, but worst case scenario I can just leave the message box as is since the print is still legible. Thank you to all who submitted.

Travis
 
I will work on the userbox
I'd use an UserForm ...
 
PHV:

Is this English Comp?

just kidding.

I just got my boxes mixed up with my forms and now I don't have anyway to store the continuous stream of papers that I give people when they come to me with a problem! :)

Travis
 
John,

Good point well made although the OP said
I am wanting to enlarge the font in the message box so it is easier to read

this is not coloured or bold text. And yes the majority of user will not change the default settings, but it'sthe ones that have that concern me.
I may code a message box to 18pt and this would seem large to me, however to the vision impaired user that has a font set to 22 by default this may cause issue.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top