+ Reply to Thread
Results 1 to 5 of 5

Command Button Caption Wrap

  1. #1
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    Command Button Caption Wrap

    Is there a way to force word wrap at a certain point for the caption on a command button inserted using the Controls Toolbox?

    I have tried to use <Alt><Enter>, <Shift><Enter>, and <Ctrl><Enter> and varying combinations with no success.

    I tried entering <Alt><0010> using the numeric keypad.

    Nothing seems to work for me...

    I would like to force a new line as follows:
    Please Login or Register  to view this content.
    and still have the button sized uniformly with other buttons which are wider than would result in the "natural" word wrap to follow the word "Final".
    Thanks!
    Dennis

    I am using Windows 7 and Office 2007, all of my posts are based on this.

  2. #2
    Registered User
    Join Date
    03-16-2004
    Location
    UK
    MS-Off Ver
    2003
    Posts
    85
    Shift and Enter seems to work for me.

    You could also try and hardcode it.
    Please Login or Register  to view this content.
    Last edited by VBA Noob; 02-27-2008 at 10:11 AM.
    Phil

  3. #3
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    I should mention...

    I am using Excel in Office 2003 and that I am using the Command Button directly on the worksheet, not in a User Form.

    Again, I did try the Shift and Enter with no success.

    I also tried to run a macro similar to your suggestion:
    Please Login or Register  to view this content.
    but it crashes with:
    Runtime Error '438'
    Object doesn't support this Property or Method.
    I am stumped.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Dennis,

    This is more involved that it first appears. This was a good question, and now you have a solution. This requires using the API to extract key information about the text so the ActiveX control (Control Toolbox) caption can be sized correctly using the control's width and the Font. Copy this macro into a VBA module. There is sample showing how to call the macro following the code.
    Please Login or Register  to view this content.
    Macro Example
    The macro adds the text to CommandButton1 on Sheet2. The sheet name is optional. If you don't specify a name then the ActiveSheet is the default.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    Thank You Leith!

    I changed the calling routine to
    Please Login or Register  to view this content.
    and it inserted the linefeed right where I wanted it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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