+ Reply to Thread
Results 1 to 9 of 9

Change length of button texts on msgbox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Change length of button texts on msgbox

    Hi,

    i am using code like in attachment to change text buttons on msgbox:

    Screenshot_15.png

    This is open code.

    What i need is to adjust length of buttons to have fully text visible (now is cutted).

    Can you help with this?
    Best Wishes,
    Jacek
    Attached Files Attached Files
    Last edited by jaryszek; 04-07-2019 at 05:43 AM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,944

    Re: Change length of button texts on msgbox

    That's an awful lot of code if all it's doing is showing a message box and controlling the size of the buttons!

    Why not just create a userform that looks and acts like a message box and call that in stead? That way you can easily size the buttons how you want them.

    BSB

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Change length of button texts on msgbox

    Hi BadlySpelledBuoy,

    thank you very much.
    Yes i can do it via userform but maybe somebody knows windows hook class to do it in very simple way and provide solution.

    Best Wishes,
    Jacek

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Change length of button texts on msgbox

    Anyone knows this class inside workbook?

    This is Windows Hooking API.

    Best,
    Jacek
    Last edited by jaryszek; 04-08-2019 at 06:54 AM.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Change length of button texts on msgbox

    There is no simple way with API. Your hook is responding after the messagebox has already been created so the size of its elements is already set. You'd need a whole load of code to resize and reposition the various elements. A userform will be the simple way.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Change length of button texts on msgbox

    Thank you Rory!

    hmm ok hmm it is possible to lock exit button on userform like in attached msgbox (it is turned off).

    Best,
    Jacek

  7. #7
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,494

    Re: Change length of button texts on msgbox

    small peace of code to do that..
    see this page http://spreadsheetpage.com/index.php..._close_button/

    Private Sub UserForm_QueryClose _
      (Cancel As Integer, CloseMode As Integer)
    '   Prevents use of the Close button
        If CloseMode = vbFormControlMenu Then
            MsgBox "Clicking the Close button does not work."
            Cancel = True
        End If
    End Sub

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Change length of button texts on msgbox

    Just trap the Userform_QueryClose event and test the closemode to see if the X was pressed:

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
       If CloseMode = vbFormControlMenu Then Cancel = True
    End Sub
    for example to just stop it working. You can also simply unload, etc.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Change length of button texts on msgbox

    Thank you!

    I am closing the topic

    Best
    Jacek

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 04-09-2019, 09:50 AM
  2. Change width of combobox dropdown to fit large texts
    By NickNunes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-30-2018, 11:04 AM
  3. Change font of all texts in one workbook?
    By OldManExcellor in forum Excel General
    Replies: 2
    Last Post: 11-26-2014, 04:55 AM
  4. Macro to search through button texts and replace
    By sm9748 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2013, 10:35 AM
  5. [SOLVED] Excel Macro to Change Texts to Proper Case, but Not Prepositions
    By haibiz9 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-18-2012, 06:21 PM
  6. MsgBox Retry button
    By Damask in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-16-2006, 10:47 PM
  7. [SOLVED] How to change tick mark labels in z axis from values to texts?
    By Flroa in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-11-2006, 01:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1