Userform Question - is this possible?

S

Stuart

I would like to show a userform, force certain textboxes
to be filled, then permit user to "Save".
"Save" would:
1. preserve the values in those textboxes.
2. export the form (with code behind the form) and
those textbox values, to a new workbook.
3. User would be able to name the new workbook
and (single) sheet, and choose the Save Folder.
4. Edit some of the code behind the form in this new
workbook to limit some of the options they had in
the original form.
5. User would then navigate to the saved book, open it,
and the saved form would be presented.

Does this seem feasible, please?

As regards 4.: the original form will be called via an addin, so perhaps
the new form's code could be stored there, and then copied into the new
workbook behind that form? If that makes sense.

Help/examples most welcome please.

Regards.
 
G

Guest

Stuart said:
I would like to show a userform, force certain textboxes
to be filled, then permit user to "Save".
"Save" would:
<snip>

All of that seems doable. You might do things in a slightly different order:

1. Export the form
2. Prompt for the name of the new Workbook, then create it.
3. Import the form into the new Workbook.
4. Copy the control settings from the old form to the new form.
5. Mess with the code in the new Workbook.

You can export the form with something like this:

Workbooks("Book1.xls").VBProject.VBComponents("Userform1").Export ("temp.bas")

and import it with

Workbooks("Book2.xls").VBProject.VBComponents.Import ("temp.bas")

You can be more specific about the file path, etc.

Export/Import preserves the layout & code of the form, but not its state.

Looping through the controls collection to copy control states is a little
tedious because each type of form has its own properties.
 
S

Stuart

Confirmation it seems "do-able" ..... Thanks.
A sample structure to get me started... Thanks again.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top