Run-time error '-2147352571'

V

Vepa

Hi

I have a strange problem with Excel VBA -code. When I try to enable the
textbox in userform called 'Parameters' I sometimes get the run time error
'-2147352571'. When I look the debug the Excel tells me that the object
variable or with block variable is not set in the following statement
Parameters.TextBox1.Enabled = True.

The interesting part is that the code works sometimes and sometimes not. For
example I have noticed that the code stops to work if I haven't used the
Excel in ca. 10 minutes. In addition, it seems that the program doesn't work
if I have multiple Excel files simulatiously open.

I would appreciate all your comments because I cannot solve this problem.

Best regards
Vepa
 
T

Tim Williams

Showing more code would help.
It may be that a variable is going out of scope under some circumstances.

Tim
 
V

Vepa

Hi,

The problem is that the code doesn't need to be any more complex than this:

private sub Commandbutton1_click
parameters.show
Call testing_init
End sub

where testing_init, initializes the textbox1 in userform called parameters.
In this case:

Private Sub UserForm_initialize()
parameters.TextBox1.Value = Sheets("Parameters").Cells(5, 4)
End sub

You mentioned that it might be so that the variables go out of scope
sometimes and I would like to know how to avoid this to happen.

Best regards
Veli-Matti
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top