Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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)



  #2   Report Post  
Junior Member
 
Posts: 1
Default

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 View Post
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)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Error 5 loading userform using Workbook_Open rjchristensen Excel Programming 1 October 16th 07 06:19 PM
Error on loading userform Trader Excel Programming 4 April 19th 07 05:00 PM
Loading a Userform Jason Zischke Excel Programming 2 March 13th 06 08:37 AM
Loading Userform Steven Cheng Excel Programming 3 December 9th 05 07:18 PM
Loading UserForm gives error Mats Samson Excel Programming 3 August 3rd 05 08:06 AM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"