Duplicate Excel worksheet and Rename

Try this Python Script, just got it working on my end. This takes in the file path and sheet names. if you just want the one, you can remove the for loop
Credit: @cgartland for the base code nabbed from
https://forum.dynamobim.com/t/formating-excel-with-dynamo-is-it-possible/39692/3

import clr
clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
from Microsoft.Office.Interop import Excel

ex = Excel.ApplicationClass()   
ex.DisplayAlerts = False
ex.Visible = True
filepath = IN[0]
sheets = IN[1]

wb = ex.Workbooks.Open(filepath)

for s in sheets:
	wb.Worksheets("Template").Copy(After =wb.Worksheets("Template"))
	wb.ActiveSheet.Name = s
wb.Save()
3 Likes