Alex Rivera | Logout

Selectable Text in VBA Message Box

Asked 2012-08-30T01:35:48.607
28

When I create a msgbox in VBA, the user cannot interact with the text at all. In my case, I want the user to be able to highlight and copy the text. I'm thinking the better way to do this may be to add a button that copies the text to the clipboard. Any suggestions?

Edit
Report

1 Answer

14

If you want text that is "selectable" then don't use MsgBox. Use a Custom form and instead of a label use a textbox. However...

Change these properties of the textbox in design mode.

  1. SpecialEffect - fmiSpecialEffectFlat
  2. BackStyle - Transparent
  3. Locked - True

And then use this code

Option Explicit

Private Sub UserForm_Initialize()
    Me.Caption = "Message Box"
    TextBox1.Text = "Hello World!"
End Sub

enter image description here

answered 2012-08-30T06:41:36.400

Your Answer