ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Loading UserForm (https://www.excelbanter.com/excel-programming/400323-error-loading-userform.html)

ZipCurs

Error Loading UserForm
 
I eager to get some help and am resubmitting this from yesterday... I have a
macro with about 20 userforms. As far as I can tell, it worked great in
earlier versions of Excel. I am now using the macro on a new machine with
Excel 2007. After I call the exact same sub-routine a bunch of times, I get:

Run-time error '75': Could not find specified object.

The debugger highlights "Load UserForm13". I can see it is right there in
VB interface and it had just accessed it 3-20 times prior to failing. I
can't open it though. There is a lot of other code, so I haven't bothered to
provide this.

Any help or guidance would greatly be appreciated. Thank you
in advance.


Jim Cone

Error Loading UserForm
 

Some general comments...
1. Hide a user form instead of unloading if you are going to display it multiple times.
2. Unload it when done with it.
3. A userform is loaded automatically when it is referenced...
UserForm13.TextBox1.Value = "Mush" - loads the form.
4. Code like this can help unload multiple userforms...

lngCounter = UserForms.Count
If lngCounter 0 Then
For N = 1 To lngCounter
Unload UserForms(N - 1)
Next
End If

5. Pioneers can get arrows in the back. (xl2007)
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"ZipCurs"
wrote in message
I eager to get some help and am resubmitting this from yesterday... I have a
macro with about 20 userforms. As far as I can tell, it worked great in
earlier versions of Excel. I am now using the macro on a new machine with
Excel 2007. After I call the exact same sub-routine a bunch of times, I get:

Run-time error '75': Could not find specified object.

The debugger highlights "Load UserForm13". I can see it is right there in
VB interface and it had just accessed it 3-20 times prior to failing. I
can't open it though. There is a lot of other code, so I haven't bothered to
provide this.

Any help or guidance would greatly be appreciated. Thank you
in advance.


Jim Cone

Error Loading UserForm
 

Oops - comment 4 code should be...

lngCounter = UserForms.Count
If lngCounter 0 Then
For N = lngCounter to 1 Step -1 '<<this line changed
Unload UserForms(N - 1)
Next
End If
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



ZipCurs

Error Loading UserForm
 
Jim,

Thanks for the advice. In the end, I just threw an "Unload UserFormXX" at
the end of each macro that was giving me problems. This seems to have done
the trick, although I have not dug in to figure out why the earlier Unload
command did not work.

Thanks again.

"Jim Cone" wrote:


Oops - comment 4 code should be...

lngCounter = UserForms.Count
If lngCounter 0 Then
For N = lngCounter to 1 Step -1 '<<this line changed
Unload UserForms(N - 1)
Next
End If
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




[email protected]

Error Loading UserForm
 
There is some bug causing the userform to crash to file. It suddenly
fails to recognize one or two of the userforms and/or reports the
error you have described. When trying to save, that is not possible.
I have a solutions with 10+ userforms, references to other libraries
and a couple of modules. I have suspected the scheduled backup of file
to have something to do with it but am I not sure. If closing the file
when picking up a cup of coffee it works fine, if leaving it even for
a short while (being idle) something has happend.

When Office 97 was released (that old, yes) I had great problems with
the userform in Word in SP-1. Learned to never save when the userform
while visible in the VB-editor. Okay to save from a code windows. Have
tried this method this time as well during some 40-50 hours spent on
the file in Office 2007 on Vista. Don't think that makes a difference
this time around.

Also found that opening the main file, from WinExplorer, while the xl?
b-file was opened, caused the original file to open in a different
instance of Excel. Realized it as I attempted to copy a module/
userform in the VB-editor. Two files open but only one visible in the
project window. Switched to the other and realized the problem. Closed
the main file and opened it from Excel and had them in the same
instance. Something is not working properly.

Regards
AK Bohman
(remove dots and garbage in the emailaddress)
www.buab.se

When leaving th
On 31 Okt, 12:39, "Jim Cone" wrote:
Some general comments...
1. Hide a user form instead of unloading if you are going to display it multiple times.
2. Unload it when done with it.
3. Auserformis loaded automatically when it is referenced...
UserForm13.TextBox1.Value = "Mush" - loads the form.
4. Code like this can help unload multiple userforms...

lngCounter = UserForms.Count
If lngCounter 0 Then
For N = 1 To lngCounter
Unload UserForms(N - 1)
Next
End If

5. Pioneers can get arrows in the back. (xl2007)
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"ZipCurs"
wrote in message
I eager to get some help and am resubmitting this from yesterday... I have a
macro with about 20 userforms. As far as I can tell, it worked great in
earlier versions of Excel. I am now using the macro on a new machine with
Excel2007. After I call the exact same sub-routine a bunch of times, I get:

Run-timeerror'75': Could not find specified object.

The debugger highlights "Load UserForm13". I can see it is right there in
VB interface and it had just accessed it 3-20 times prior to failing. I
can't open it though. There is a lot of other code, so I haven't bothered to
provide this.

Any help or guidance would greatly be appreciated. Thank you
in advance.



sriharid

I understand that this is a fairly old thread but I couldn't find any other bulletin board on the Internet where this problem was described exactly as I see it.

I have a macro with 3 user forms that are all modal and either one of them is visible depending on user action (clicking on next/previous buttons). The user runs the macro by clicking a button in the Excel workbook. When transitioning from one form to the next, I hide the current form and show the next one. Forms are unloaded only when exiting the macro (which happens when the user clicks on a couple of buttons on each of the forms). The forms themselves are simply for text input and one of the buttons on the form causes the values entered in the form to be committted to a sheet in the excel workbook.

Intermittently, I get the "Run-time error 75: Could not find specified object" popup when I try to re-run the macro. When I hit Debug it goes to the code where the first user form is being loaded. Sometimes, when I am making changes to the VB code (while the macro is not running) and I try to save the workbook, Excel crashes.

I have not been able to notice

The code used for unloading forms is:
<code
Dim form As UserForm
For Each form In VBA.UserForms
Unload form
Next form
</code

I have also used the following (which is the code suggested by Jim Cone), but the problem still remains and I think this loop is functionally equivalent to the above loop anyways:
<code
For i = VBA.UserForms.Count - 1 To 0 Step -1
Unload VBA.UserForms(i)
Next i
</code

I have gone through my code several times and I feel that this is a bug in Excel, but given that not many people have reported it, I am starting to wonder what might be causing it. Can someone help?

Quote:

Originally Posted by ZipCurs (Post 1420373)
Jim,

Thanks for the advice. In the end, I just threw an "Unload UserFormXX" at
the end of each macro that was giving me problems. This seems to have done
the trick, although I have not dug in to figure out why the earlier Unload
command did not work.

Thanks again.

"Jim Cone" wrote:


Oops - comment 4 code should be...

lngCounter = UserForms.Count
If lngCounter 0 Then
For N = lngCounter to 1 Step -1 '<<this line changed
Unload UserForms(N - 1)
Next
End If
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





All times are GMT +1. The time now is 08:46 AM.

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