ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error '-2147352571' (https://www.excelbanter.com/excel-programming/420115-run-time-error-2147352571-a.html)

Vepa

Run-time error '-2147352571'
 
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


Tim Williams

Run-time error '-2147352571'
 
Showing more code would help.
It may be that a variable is going out of scope under some circumstances.

Tim

"Vepa" wrote in message
...
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




Vepa

Run-time error '-2147352571'
 
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

"Tim Williams" wrote:

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

Tim

"Vepa" wrote in message
...
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





Tim Williams

Run-time error '-2147352571'
 
Have you tried initializing the form before showing it ?

Tim


"Vepa" wrote in message
...
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

"Tim Williams" wrote:

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

Tim

"Vepa" wrote in message
...
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








All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com