Create a vba message box that uses html

How can I return a message box with valid HTML tags using VBA? example

    dim mtext as string
    mtext = "<em>hello</em> <br> world"
    msgbox mtext

      

+3


source to share


2 answers


Not. A function MsgBox

is just a thin wrapper over a Win32 API function and is not relevant to HTML input. HTML is for web browsers, not desktop applications.

The closest you can get is a custom one UserForm

with a control RichTextBox

, but that's an OCX technology designed for Visual Basic 6.0 and probably won't work on x64 machines, not to mention it will definitely break if you need to redistribute its own macro for users who do not have OCX on their computers.




A better alternative might be to create a COM Visibility Class Library in your favorite .NET language (C #, VB.NET) and publish a custom function MessageBox

that displays a WinForms dialog with a control System.Windows.Forms.RichTextBox

that can handle and display rich text in RTF format.

Then you need to distribute and register your COM type library for your users.

In other words, it can be done - it only depends on how badly you want it.

+2


source


I would create a custom form design and then create a text based on your needs. May I ask why you want to use HTML codes? The reason might be simple enough to create your own library / class to handle the processing before clicking on the rich text box. However, the Rich Text Box will only be in VB, for example using VB Studio Express. With VBA you are stuck ... sorry.



0


source







All Articles