PDA

View Full Version : autofit msgbox to text length



smakatura
08-09-2023, 10:12 AM
my msgbox is too short and a line of text moves to two lines.

I want the line of text to be on one line.
All text is showing in the msgbox, just not on one line
the text length could change randomly


Is there an option to 'autofit' the msgbox


Dim answer As Integer
Dim PullFromPPTFileName As String

PullFromPPTFileName = "Figure 121. Gonorrhea - Rates by Year, Tucson Total, 2017-2021.pptx"

answer = MsgBox("The current file to be uploaded is" _
& vbCrLf & _
PullFromPPTFileName _
& vbCrLf _
& vbCrLf & _
"Would you like to upload the correct file and try again?", _
vbQuestion + _
vbYesNo + _
vbDefaultButton1)
If answer = vbYes
Then MsgBox "Yes"
Else MsgBox "No"
End If

Paul_Hossler
08-11-2023, 10:07 AM
The vbCrLf's will start another line

Am I missing something?

But IIRC Msgbox's are always the same size. You could just use a UserForm

Aussiebear
08-11-2023, 01:10 PM
I believe that line length is limited to 1024 characters for message boxes. Paul kindly offered this insight at this thread as well. http://www.vbaexpress.com/forum/showthread.php?64758-MessageBox-line-length

Paul_Hossler
08-11-2023, 01:16 PM
Paul kindly offered this insight at this thread as well. http://www.vbaexpress.com/forum/showthread.php?64758-MessageBox-line-length

Gee, forgot all about that post and example

I have that and other code snippets in a 'library' xlsm

Aussiebear
08-11-2023, 01:28 PM
Well you did hint that you are not Gen Z, sometime ago.... :devil2: