+ Reply to Thread
Results 1 to 4 of 4

input box - I don't need the "cancel" button

  1. #1
    Paula
    Guest

    input box - I don't need the "cancel" button

    I am using an input box and have it set up so that it can't be left empty,
    but I can't get rid of the cancel button (even though it doesn't do
    anything). I know it can be done, but it's escaping me at the moment...any
    assistance would be appreciated.
    --
    Thanks - Paula

  2. #2
    Dave Peterson
    Guest

    Re: input box - I don't need the "cancel" button

    I don't think you can change the way the inputbox works.

    One option is to design your own form and do exactly what you want.

    Debra Dalgleish has some get started instructions for userforms at:
    http://contextures.com/xlUserForm01.html

    Or maybe you could just tell them what you'll use instead:

    Option Explicit
    Sub testme02()

    Dim myStr As String
    Dim myDefault As String

    myDefault = "hi There!"
    myStr = InputBox(Prompt:="enter something or I'll use the default", _
    Default:=myDefault)

    If myStr = "" Then
    myStr = myDefault
    End If

    MsgBox myStr

    End Sub



    Paula wrote:
    >
    > I am using an input box and have it set up so that it can't be left empty,
    > but I can't get rid of the cancel button (even though it doesn't do
    > anything). I know it can be done, but it's escaping me at the moment...any
    > assistance would be appreciated.
    > --
    > Thanks - Paula


    --

    Dave Peterson

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hi Paula,

    The best thing to do is follows Dave's advice, since Excel doesn't provide any direct means of removing the Cancel button thorugh the InputBox properties. It can be done using API calls, but the complexity far outweighs the ease and versatility you can get by creating a UserForm. However if you are really interested in the API method, let me know.

    Sincerely,
    Leith Ross

  4. #4
    Chip Pearson
    Guest

    Re: input box - I don't need the "cancel" button

    Dave's procedure doesn't discern the difference between pressing
    Enter with an empty string and pressing the Cancel button.
    Instead, try the following procedure.

    Dim myStr As String
    Dim myDefault As String

    myDefault = "hi There!"
    myStr = InputBox(Prompt:="enter something or I'll use the
    default", _
    Default:=myDefault)
    If StrPtr(myStr) = 0 Then
    MsgBox "You pressed cancel"
    Else
    MsgBox myStr
    End If


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com






    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    >I don't think you can change the way the inputbox works.
    >
    > One option is to design your own form and do exactly what you
    > want.
    >
    > Debra Dalgleish has some get started instructions for userforms
    > at:
    > http://contextures.com/xlUserForm01.html
    >
    > Or maybe you could just tell them what you'll use instead:
    >
    > Option Explicit
    > Sub testme02()
    >
    > Dim myStr As String
    > Dim myDefault As String
    >
    > myDefault = "hi There!"
    > myStr = InputBox(Prompt:="enter something or I'll use the
    > default", _
    > Default:=myDefault)
    >
    > If myStr = "" Then
    > myStr = myDefault
    > End If
    >
    > MsgBox myStr
    >
    > End Sub
    >
    >
    >
    > Paula wrote:
    >>
    >> I am using an input box and have it set up so that it can't be
    >> left empty,
    >> but I can't get rid of the cancel button (even though it
    >> doesn't do
    >> anything). I know it can be done, but it's escaping me at the
    >> moment...any
    >> assistance would be appreciated.
    >> --
    >> Thanks - Paula

    >
    > --
    >
    > Dave Peterson




+ 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