问题
I have a worksheet that looks like a form. It has a "Reset" button to clear the values.
There is a macro that I can run that copies that sheet into a new Workbook and emails it to someone. The module that contains the macros gets copied into it and all is almost ok. The problem is, the button on the worksheet that runs the reset macro still points back to the original document. How can I have it point to the macro within itself?
Edit: One thing to point out is that I do have macros within that sheet that fire off if cells are changed. Those work great and don't try and load the original file. It's just the ones within the button that don't work.
回答1:
You should use 'ActiveX form button' instead of 'simple form button' (which I guess you use). Then you have to put reset procedure within ActiveX button event (double click on it to edit that procedure). As the result of coping the sheet both button and the procedure would be moved to new workbook which will break any reference to original file.
来源:https://stackoverflow.com/questions/15392447/copy-a-worksheet-to-a-new-workbook-and-have-a-button-point-to-the-macro-in-the-n