开发者

How is non-standard worksheet.object created in this Excel VBA

The following VBA 6 in Excel 2000 code

Resides in a form that has text boxes, comboboxes and buttons One of them is txtUsername, another is txtPassword --I inherited this code

With shtName
.Unprotect "thepassword"
.range("somenamedrange").Value = cboComboBox.Value
.txtUsername.Text = txtUsername.Text
.txtPassword.Text = txtPassword.Text
...
End With  

The code sets a text value for two worksheet objects that appear in the VBA Editor Object list, but are neither defined nor set anywhere else in the Excel Project. Option Explicit is used on all Microsoft Excel Objects, Forms and Modules. I can create procedures for said worksheet objects on said worksheet in the VBA Editor (e.g.,

Private Sub txtUsername_Change()  

End Sub

开发者_运维百科Neither object

worksheet.txtUsername

worksheet.txtPassword

appears nor is set as a named range.

The value of both objects is only used elsewhere by specific reference worksheet.txtUsername.Text

These values do not show up in the locals window after they are set on the worksheet. They are definitely used, as the Essbase queries complete successfully using these objects.

summary: i understand formName.txtUsername.Text (or .Value)

i do not understand a worksheet object that does not get defined nor instantiated via code

the only bright idea I had was to export the worksheet and view in a text editor, to see if my ancestors created a "custom" worksheet object the way one defines a "default property" in a class module--manually via text editor (no mention of either property in the worksheet.cls)

Thank you.


Worksheets that are part of the Excel spreadsheet do not have to instantiated, they're part of the workbook and just "always there". If they're not visible to the user but are visible in the project browser, there could be some code in the "ThisWorkbook" section that make the sheets invisible (.visible = false) when the workbook launches.


I found that the VBA Code Cleaner cleaned "references to object definitions that cannot be found".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜