T
tr00per
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
(e-mail address removed)
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
(e-mail address removed)