Consulting

Results 1 to 5 of 5

Thread: autofit msgbox to text length

  1. #1

    autofit msgbox to text length

    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
    Last edited by Paul_Hossler; 08-11-2023 at 10:07 AM. Reason: Amended the tags used to wrap the supplied code

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    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/show...ox-line-length
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Quote Originally Posted by Aussiebear View Post
    Paul kindly offered this insight at this thread as well. http://www.vbaexpress.com/forum/show...ox-line-length
    Gee, forgot all about that post and example

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

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Well you did hint that you are not Gen Z, sometime ago....
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Tags for this Thread

Posting Permissions

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