Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/130108

From BetaArchive Wiki

Article ID: 130108

Article Last Modified on 10/11/2006


  • Microsoft Excel 5.0 Standard Edition
  • Microsoft Excel 5.0 for Macintosh
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0c
  • Microsoft Excel 5.0 Standard Edition
  • Microsoft Excel 5.0a for Macintosh

This article was previously published under Q130108


When you run a Microsoft Visual Basic for Applications subroutine in Microsoft Excel, you may receive the following macro error message:

Runtime Error 1005:
Unable to Set the Text Property of the Editbox Class

This error will occur if the following conditions are true:

  • A macro tries to set the Text property of an edit box on a protected dialog sheet.


  • The workbook has been closed and reopened since protecting the dialog sheet.

Note that this problem also occurs with check boxes (both on dialogs and also on worksheets).


To change the text of an edit box on a protected dialog sheet, the Lock Text check box must be cleared. The Lock Text check box is located on the Protection tab of the Format Object dialog box for that edit box. When the file is saved, closed, and reopened, the Lock Text check box is reset.


Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To change the Text property of an edit box by using a Visual Basic for Applications (VBA) subroutine, use one of the following methods.

Method 1

Unprotect the dialog sheet before you change the edit box text, and then reprotect the dialog sheet. The following example uses the Unprotect method to unprotect a dialog sheet that is named "Dialog1." It then changes the text of an edit box that is named "Edit Box 4," and then reprotects the Dialog Sheet.

    ' You can skip this line if you are adding this code to
   ' an existing macro.
   Sub ChangeEditBox()

      ' Unprotect the dialog sheet. If a password is required,
      ' remove the apostrophe in front of password and
      ' change "MyPassword" to the correct password.
      DialogSheets("Dialog1").Unprotect 'password:="MyPassword"

      ' Change the edit box text to "Hello." You should verify and
      ' change "Edit Box 4" to the correct name.
      DialogSheets("Dialog1").EditBoxes("Edit Box 4").Text = "Hello"

      ' Reprotect the worksheet. If a password is required,
      ' remove the apostrophe in front of password and change
      ' "MyPassword" to the correct password.
      DialogSheets("Dialog1").Protect 'password:="MyPassword"

   End Sub

Method 2

Leave the dialog sheet unprotected.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.


For more information about the Text Property, click the Search button in Visual Basic Reference Help and type:

Text Property

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

113599 Can't Format Control Text in Objects Such As EditBox and Range

Additional query words: editbox dialogsheet checkbox XL Err Msg

Keywords: kberrmsg kbbug kbprogramming kbcode KB130108