View Single Post
 
Old 04-28-2020, 02:10 PM
marceepoo marceepoo is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default Userform textbox control missing/invisible; can't find, use or replace it; how to salvage work on a

I made a userform named, “frmTOE_ExhMakeFromData01” which contains a textbox control named, “txHyperlinkzName”

The textbox control disappeared. I assumed that I must have inadvertently deleted it during the weeks I’ve been working on the userform, and I tried to recreate the textbox, “txHyperlinkzName”

But when I tried to assign the named “txHyperlinkzName” to the new textbox control, a message from Windows VBA said:
Could not set the Name property. Ambiguous name.

Hoping to make the textbox control prominent in the userform so that I could find it among the many controls on the userform, I ran a sub which assigned a vibrant color to the control’s background property, and I assigned text to the textbox’s text property. To no avail; the textbox still was not visible.

I ran the following sub to get a list of all of the controls in the userform:

Code:
Sub subUserformControls_Output2TxFile(sFormName As UserForm)
    'https://stackoverflow.com/questions/25248034/how-do-i-list-print-control-names-and-or-properties-on-a-vba-form
    Dim ctlLoop As MSForms.Control
    Dim sMsgboxMsg As String
    Dim sDateTime As String
    sDateTime = CStr(Format(Now(), "yyyy-mm-dd_hh-mm-ss"))
    sMsgboxMsg = sDateTime
    
    For Each ctlLoop In sFormName.Controls
        sMsgboxMsg = sMsgboxMsg & vbCrLf & _
           CStr(TypeName(ctlLoop)) & ":" & CStr(ctlLoop.Name)
    Next ctlLoop
    
    Call subWrite2TxtFileAndOpenInEditPadPro(sMsgboxMsg)
    
End Sub ' subUserformControls_Output2TxFile(sFormName)
I think that the foregoing is the sub I used (and of which I was very proud); but the sub now only produces the error message:
Run-time error '91':
Object variable or With block variable not set

That sub or some other version (of that sub) which I inadvertently deleted, produced an output listing all of the controls in the form, and the list did indeed include a textbox control named, “txHyperlinkzName”

Questions:
A. What did I do to cripple the sub above?
B. What do I do now?
1. Should I just create a new textbox control and put it where the missing one was, and continue working on the form? or ...
2. Should I presume that the file is corrupt and that continuing to work on its development is a waste of time? In other words, should I start over on my userform from scratch? or ...
3. I created my userform in the VBA IDE, dragging textboxes, labels, cmd buttons, etc. onto a canvas. But I think people with more knowledge than I have, create userforms entirely by VBA. In other words, are there VBA techniques I could use to:
a. Extract from my userform all the properties of each control (frames, textboxes, labels, cmd btns, option btns, etc.) including the location information (i.e., where they were situated in the userform, and the size (length and width) of the control)?
b. Use the extracted info to re-create the userform?

Thank you for any advice.

Marc
Reply With Quote