none
Input box question RRS feed

  • Question

  • I have the follow input box question that I want the input to always be upper case letters. If a user would enter ‘a’ it would change it to ‘A’. Is this possible?

     

     

    DivWk = InputBox("WHAT DIVISION WORK WEEK IS THIS SCHEDULED FOR?")

    If ActiveDocument.Bookmarks.Exists("Division") Then

         Set myRange = ActiveDocument.Bookmarks("Division").Range

         myRange.Text = DivWk

         ActiveDocument.Bookmarks.Add "Division", myRange

    End If

    Saturday, December 3, 2011 3:31 PM

Answers

  • Use

    DivWk = UCase(InputBox("WHAT DIVISION WORK WEEK IS THIS SCHEDULED FOR?"))
    

    The UCase function converts a string to upper case.


    Regards, Hans Vogelaar
    Saturday, December 3, 2011 4:05 PM
  • Thank You Hans. That worked.
    • Marked as answer by fuzzhead58 Saturday, December 3, 2011 4:09 PM
    Saturday, December 3, 2011 4:09 PM
  • There is nothing better here that what you've discovered.  Just a preference:

    1.  Always declare varialbes

    2.  You don't really need a DivWk variable

    3.  You can use error handling to eliminate the If ... End If statement:

    Sub ScratchMacro()
    Dim oRng As Word.Range
    With ActiveDocument
      On Error GoTo lbl_Exit
      Set oRng = .Bookmarks("Division").Range
      oRng.Text = UCase(InputBox("ENTER THE TEXT", "ENTRY"))
      .Bookmarks.Add "Division", oRng
    End With
    lbl_Exit:
    Exit Sub
    End Sub


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm
    • Marked as answer by fuzzhead58 Tuesday, September 9, 2014 3:06 PM
    Saturday, December 3, 2011 9:36 PM

All replies

  • Use

    DivWk = UCase(InputBox("WHAT DIVISION WORK WEEK IS THIS SCHEDULED FOR?"))
    

    The UCase function converts a string to upper case.


    Regards, Hans Vogelaar
    Saturday, December 3, 2011 4:05 PM
  • Thank You Hans. That worked.
    • Marked as answer by fuzzhead58 Saturday, December 3, 2011 4:09 PM
    Saturday, December 3, 2011 4:09 PM
  • There is nothing better here that what you've discovered.  Just a preference:

    1.  Always declare varialbes

    2.  You don't really need a DivWk variable

    3.  You can use error handling to eliminate the If ... End If statement:

    Sub ScratchMacro()
    Dim oRng As Word.Range
    With ActiveDocument
      On Error GoTo lbl_Exit
      Set oRng = .Bookmarks("Division").Range
      oRng.Text = UCase(InputBox("ENTER THE TEXT", "ENTRY"))
      .Bookmarks.Add "Division", oRng
    End With
    lbl_Exit:
    Exit Sub
    End Sub


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm
    • Marked as answer by fuzzhead58 Tuesday, September 9, 2014 3:06 PM
    Saturday, December 3, 2011 9:36 PM