Consulting

Results 1 to 16 of 16

Thread: Solved: Msgbox formatting the text

  1. #1

    Solved: Msgbox formatting the text

    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

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Why not use a userform.....you can make it look any way you wish.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Quote Originally Posted by lucas
    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

  4. #4

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Example attached:
    in the thisworkbook module look for the workbook open code. It calls the sub in the module1 that shows the userform
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    I just make everyone install the addins I have installed. LOL!

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Rascal
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    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?

  10. #10
    Almost forgot, is there a way to make a Userform popup on closing the workbook?

    Thanks again for all the help

  11. #11
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    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 ...

    [vba]Load MyUserForm[/vba]

    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.

  12. #12
    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)

  13. #13
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    It's made to call just like a regular MsgBox (only ktMsgBox).

  14. #14
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Check out this userform with no title bar, etc.
    shows how flexible a form is compared to a messagebox
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  15. #15
    Quote Originally Posted by lucas
    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.

  16. #16
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Paul,
    Glad to help.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •