Saqib Husain
asked on
VBA - How to create a workbook containing workbook event handlers as well as userforms.
I have a workbook which generates blank monthly timesheets for individual employees. The employee selects the name, designation, month and year and clicks a button. This copies a blank timesheet worksheet (which contains macros in the worksheet module) to a new workbook. The new workbook is ready with the worksheet event handlers for the individual.
I now need to extend the capabilities of the workbook to have workbook event handlers and also userforms. I am not clear on how to use VBA to create such workbooks.
One way I can see is to use a macro to write the macros. But this means that every individual's computer should have this feature enabled. I do not think I can go with this.
Another way could be to copy the entire workbook to a new workbook (I am not sure how I would do that) and then delete the other sheets which are not supposed to be copied over. But then the workbook module would contain all the macros related to generating the new workbook in addition to the ones needed to use the timesheet.
Can someone guide me or suggest any other method to be able to copy the macros to a new workbook?
I now need to extend the capabilities of the workbook to have workbook event handlers and also userforms. I am not clear on how to use VBA to create such workbooks.
One way I can see is to use a macro to write the macros. But this means that every individual's computer should have this feature enabled. I do not think I can go with this.
Another way could be to copy the entire workbook to a new workbook (I am not sure how I would do that) and then delete the other sheets which are not supposed to be copied over. But then the workbook module would contain all the macros related to generating the new workbook in addition to the ones needed to use the timesheet.
Can someone guide me or suggest any other method to be able to copy the macros to a new workbook?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This method avoids accessing code through code
ThisWorkbook.SaveCopyAs "C:\Full\Path\To\File.xls"
Kevin