XL Err Msg: Unable to Set the Text Property of Editbox ClassLast reviewed: December 1, 1997Article ID: Q130108 |
The information in this article applies to:
SYMPTOMSWhen 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 ClassThis error will occur if the following conditions are true:
CAUSETo 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.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.aspTo change the Text property of an edit box using a Visual Basic for Applications subroutine, use one of the following methods.
Method 1Unprotect 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 named "Dialog1." It then changes the text of an edit box 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 2Leave the dialog sheet unprotected.
STATUSMicrosoft has confirmed this to be a problem in versions of Microsoft Excel listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
REFERENCESFor more information about the Text Property, choose the Search button in Visual Basic Reference help and type:
Text PropertyFor additional information, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q113599 TITLE : Can't Format Control Text in Objects Such As EditBox and Range ARTICLE-ID: Q125422 TITLE : XL5: Creating a Masked Password Dialog Box in Visual Basic |
Additional query words: editbox dialogsheet checkbox
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |