Making a copy of a sheet within an ADDIN
Posted by Jack on December 04, 2001 1:53 PM
I have an Excel 97 ADDIN which has 3 worksheets, one of which is a template I want to export. I want to copy this sheet within the ADDIN (creating a 4th sheet), rename it, then move it to the users active workbook. The procedure works fine as an XLS file but not as an ADDIN
The line of code is:
ThisWorkbook.Sheets("Template").Copy After:=ThisWorkbook.Sheets(3)
In the xls it creates "Template (2)" as a 4th sheet. As an ADDIN I get "Runtime error 1004 - Copy method of worksheet class failed"
I tried everything I can think of including Walkenbach's Power programming, but his examples only include copying a sheet from the addin to the active workbook , or to a new workbook, which I can do.
Any suggestions?