cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Fabrizio_Ruo
Level II

Overwrite Excel Sheet

I can create new sheets in a Excel file using "Create Excel Workbook" without any issue only if the sheets do not exist in the excel file.

The problem come when the sheets already exist in the excel file and I try to overwrite them.

There are some cells that remains with the old data, and I do not want them!

 

Is there a way to have a full overwite of the sheets usign "Create Excel Workbook" ?

Is there a way to delete a single sheet in an Excel file?

 

Thanks,

Fabrizio

 

 

4 REPLIES 4

Re: Overwrite Excel Sheet

Hi Fabrizio,


Create Excel Workbook tries to do a replacement if the file already exists and the worksheet names match existing worksheet names.  If that is not the case, it creates new sheets.  Unfortunately, there is no way to override the behavior other than to provide different sheet names or a different file name prior to the save.

 

Brian Corcoran

JMP Development

Fabrizio_Ruo
Level II

Re: Overwrite Excel Sheet

Hi Brian,

is there a way to delete a single sheet from an Excel file?

 

Thanks,

Fabrizio

Re: Overwrite Excel Sheet

Hi Fabrizio,

 

Sorry, no, there are no circumstances where we delete sheets from an existing workbook.

 

Brian

jimmsky
Level I

Re: Overwrite Excel Sheet

//I hope this will help you, this will delete your workbook
excel_path = "$Desktop\test.xlsx"
save text file(delSheetpath = "$Desktop\deleteExcelSheet.vbs",

"\[
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim oExcel
Set oExcel = CreateObject("Excel.Application")

Dim oBook
Set oBook = oExcel.Workbooks.Open("]\"||excel_path||"\[")

oExcel.DisplayAlerts = False
oExcel.ScreenUpdating = False

oBook.sheets("]\"||sheet_name||"\[").Delete

oBook.save
oBook.close

oExcel.DisplayAlerts = True
oExcel.ScreenUpdating = True

oExcel.Quit

]\"
);

open(delSheetpath);