PDA

View Full Version : Solved: Msgbox formatting the text



Paul C
07-03-2006, 10:06 AM
Can anyone help me, I have a msgbox that opens whenever i open my workbook, I want to format the text in the msgbox so that its red and bold maybe italic, but have no idea how to do this,can someone please give me a example of a simple msgbox with the correct code for formatting the text, I would really appreciate it

Regards

lucas
07-03-2006, 10:24 AM
Why not use a userform.....you can make it look any way you wish.

Paul C
07-03-2006, 11:34 AM
Why not use a userform.....you can make it look any way you wish.

Hi Steve,I am very new to VBA, how would i get a userform to open automatically when i open and one to open when i close the workbook?


Thanks

Paul

Zack Barresse
07-03-2006, 11:51 AM
Hi there!

Check out ktMsgBox by Colo ...


http://www.h3.dion.ne.jp/~sakatsu/ktMsgBox_Series_English.htm

lucas
07-03-2006, 11:52 AM
Example attached:
in the thisworkbook module look for the workbook open code. It calls the sub in the module1 that shows the userform

lucas
07-03-2006, 11:59 AM
Colo's solution works well enough but its not portable enough for me......I'd rather use a form and it goes where the workbook goes. With Colo's code everyone that uses the file must have the addin I think. Correct me if I'm wrong Zack

Zack Barresse
07-03-2006, 12:01 PM
I just make everyone install the addins I have installed. :D LOL!

lucas
07-03-2006, 12:04 PM
Rascal :devil2:

Paul C
07-03-2006, 12:29 PM
Thanks Zack and Steve, its much appreciated, one more thing is it possible to get rid of the ugly blue title bar on the userform?

Paul C
07-03-2006, 12:37 PM
Almost forgot, is there a way to make a Userform popup on closing the workbook?

Thanks again for all the help

Zack Barresse
07-03-2006, 12:57 PM
Hi Paul,

To answer your second question first, yes. From Excel, right click the workbook icon directly to the left of the File menu and select View Code. From there it opens the Visual Basic Editor to your ThisWorkbook module (one per workbook/project). On the right should be a big blank pane and above it should be two drop down boxes. Select the left one and select Workbook. Now select the right one and select Close. This will give you the basic code syntax for your workbook_close event.

Now this will run when you close a workbook. To load a userform, use something like this ...

Load MyUserForm

Note that if you do not have any other handling or cascading events, the workbook will close when you close the form. If you need to stop this, some other events will need to be placed, or a global variable of sorts will need to be used.

As for your first request, I don't know of a way. This doesn't mean it can't be done though.

Paul C
07-03-2006, 01:27 PM
Thanks for the reply Steve, At the risk of getting a reputation for being a idiot may i ask another question? I have looked at the ktmsgbox you recommended,it looks good, I have managed to work out how to generate a custom msgbox using the ktMsgbox Trial, how do i get it to popup in a Msgbox? here is a example of the code,I have tried inserting it into a module using the Sub Auto_Open() command as i normally do but its not working, any ideas?

Dim Prompt As kt_MsgBoxPromptType
Dim rc As Variant
Call ktMsgBoxPromptTypeInit(Prompt)
With Prompt
.Message(1) = "Hello"
.FName(1) = ""
.FSize(1) = 11
.FBold(1) = True
.FColor(1) = vbRed
End With
rc = ktMsgBoxEX(Prompt _
, vbOKOnly + vbExclamation, "ktMsgBox Wizard" _
, BackColor:=vbWhite)

Zack Barresse
07-03-2006, 01:40 PM
It's made to call just like a regular MsgBox (only ktMsgBox).

lucas
07-03-2006, 02:36 PM
Check out this userform with no title bar, etc.
shows how flexible a form is compared to a messagebox

Paul C
07-04-2006, 06:35 AM
Check out this userform with no title bar, etc.
shows how flexible a form is compared to a messagebox

Wow i am impressed, thanks very much for all your help Steve.

lucas
07-04-2006, 07:59 AM
Hi Paul,
Glad to help.