Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switch Workbook.Open forms

Status
Not open for further replies.

dnelson24

IS-IT--Management
Apr 1, 2002
59
0
0
US
I have a form that opens with the workbook. I would like to switch this form with another after the initial workbook does a saveas to another file name and closes itself without saving any changes. I would like the saveas file to have the new form open when it opens up.

I need help with the VB code to do this!
Thanks
David
 
Let me get this straight...

You open a file and Userform1 shows up.
Then you do a save-as and close the (new) file.
Then when you re-open the new file you want Userform2 to show up.

It sounds like you are using the original file as a template. If the original file is read-only, have your Auto-Open procedure check to see if the file is read-only. If it is, show Userform1. If it is not, show Userform2.

If the original file is not read-only, then put a character in an unused cell. Within your save-as procedure, clear the contents of that cell. In your auto-open procedure, check the contents of that cell. If there is something there, you have opened the original, if it is empty, you have opened a copy. The same sort of thing can be done using a very-hidden worksheet.
In essence, something about the new file must be different than the old file. Check the difference to see which one opened and show the appropriate userform.

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top