LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default why does userform close after programming worksheet event with CreateEventProc or AddFromString

I have a problem that I hope someone might be able to help with.
Thanks in advance for any help.

Background:
For an excel project, I have created a userform that runs automatically
upon opening the workbook. To simplify the example, let's say the
userform contains only a textbox and commandbutton controls. The
commandbutton control adds a new worksheet to the workbook (using
Worksheets.Add) and then sets the .Name of the newly added worksheet
equal to the .Value of the textbox on the userform. The code then uses
..CreateEventProc to programmatically code an event (let's say the:
Worksheet_Calculate(), event). Lastly, I "close" the VBE with:
Application.VBE.MainWindow.Visible = False. All of the above works
correctly - i.e. the worksheet is added to the workbook and is
correctly named, Worksheet_Calculate() event is correctly written to
the new worksheet, etc.

Finally, the problem...the userform closes. I would prefer that the
userform remain open with the user's previous input values still
present in the form. I'm not really sure why the userform goes away,
but it seems like the project stops running. Is it possible to regain
view of the userform after closing the VBE? Or, do I possibly have to
tediously save the relevant properties (.Value, .Visible, etc) of each
control so that I can at least re-show the userform and reset the
properties after closing the VBE?

Also, the userform still closes / is no longer accessible even if I use
..AddFromString instead of .CreateEventProc. The one advantage I found
using .AddFromString is that the VBE doesn't launch.

Sorry for being so long-winded about this. If you would like to see
the actual code that I have written, please let me know so that I can
get back to you. Otherwise, I hope you can help me with this or at
least get me pointed in the right direction toward a solution.

Thanks again,
Coop


 
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
Close UserForm despite Exit Event Carim[_3_] Excel Programming 4 May 17th 05 05:39 AM
Worksheet close event++? has ex Excel Programming 1 April 13th 05 12:05 AM
Worksheet close event? has ex Excel Programming 4 April 12th 05 11:43 PM
Event procedures for controls added with CreateEventProc John Austin[_6_] Excel Programming 7 March 24th 05 03:21 PM
Event procedures for controls added with CreateEventProc John Austin[_5_] Excel Programming 0 March 12th 05 09:33 PM


All times are GMT +1. The time now is 10:22 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"