I am developing a workbook that will serve as a template for multiple users. I am currently attempting to develop an auto-open code that will format the initial display of the worksheet. I have a code that, once finished running, will open 2 windows, displaying 2 separate worksheets. One window will be the worksheet for data input, the second window is for associated macro command buttons. I have 2 problems:
1. When I wrote the code using the macro recorder feature, the resulting code includes the specific file name in the window command. For example, the first line of text reads:
Windows("LatestPCA-012113-1.xlsm:1").Activate
Whenever the user starts to use this template, they are to rename the file for their respective project. The Code however, does not recognize that new name. How do I re-write the code so that it recognizes the current file name, not the name of the template of origin?
2. The Code is designed assuming there are already 2 windows open in the saved workbook. If the user saves the workbook after closing one of the open 2 windows, the Code will no longer work. The Code reads:
Windows("LatestPCA-012113-1.xlsm:1").Activate
ActiveWindow.Close
As you can see, if there is only 1 window open, the above code immediately closes that single window, leaving nothing to display.
How can I re-write this code to close one of the 2 windows, if there are 2 windows open in the saved documents, but to not close the window if there is only 1 window open?
Thanks
Bookmarks