Home > Software engineering >  Help save a workbook is only delete operation table and macro code, name of the file can be customiz
Help save a workbook is only delete operation table and macro code, name of the file can be customiz

Time:09-17

XLSM file can set up a file save as function, at the same time only delete the operating table and macro code, generated. XLS file

CodePudding user response:

Refer to the following this code,
Respectively is: how to delete the specified working table, how to specify save "format",
 Sub Main () 
Application. DisplayAlerts=False 'close the warning
'if you don't shut down, the following two sentences executes the pop-up dialog let user to confirm
Sheets (" Sheet3 ".) Delete 'to Delete specified worksheet
'pay attention to the following "save as... Operation:
"'1. The file named ABC, didn't give the extension, Excel will automatically add the correct extension
'2. In the case of "warn off", the target file exists is not prompt, direct cover
ThisWorkbook. SaveAs "E: \ Temp \ TestE xlExcel12, CreateBackup:=False
Application. DisplayAlerts=True 'recovery warning
End Sub

CodePudding user response:

The above code, to the "file name" is TestE, save the result file is TestE XLSX,
Like the above code line 9, don't give the extension, then cannot exist the folder "E: \ Temp \ TestE",
If you have this folder, could operation error, this time should be given extension, a written E: \ Temp \ TestE XLSX

CodePudding user response:

Just clean up the test file, found that more than a file...
The original "type" parameter to write wrong, should be xlOpenXMLWorkbook,


 ThisWorkbook. SaveAs "E: \ Temp \ TestE xlOpenXMLWorkbook, CreateBackup:=False 
  •  Tags:  
  • VBA
  • Related