如何另存(保存)不含宏
首先贴出原文:
http://club.excelhome.net/thread-1105587-1-1.html
1 '-----------Sub 仅存数据----------Copyright@百度不到去谷歌 QQ80871835 2014/3/22--------------------------- 2 '功能 : 另存为不含宏的文件,并删除控件,条件格式,数据有效性,公式转数值 3 '--------------------------------------------------------------------------------------------------------- 4 Sub 仅存数据() 5 Dim sht, shp 6 Application.DisplayAlerts = False 7 ActiveWorkbook.SaveAs Filename:= _ 8 ActiveWorkbook.Path & "" & ActiveWorkbook.Name & "-纯数据.xlsx", FileFormat:=xlOpenXMLWorkbook '另存为xlsx格式 清除宏代码 9 Sheets.Select 10 Cells.Select 11 Selection.Copy '粘贴数值,删除公式 12 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ 13 :=False, Transpose:=False 14 Application.CutCopyMode = False 15 Sheets(1).Select 16 For Each sht In Sheets '删除控件 17 With sht 18 .Cells.FormatConditions.Delete '删除条件格式 19 For Each shp In .Shapes '清除控件 20 shp.Delete 21 Next 22 .Cells.Validation.Delete '清除有效性 23 End With 24 Next 25 ActiveWorkbook.Save 26 Application.DisplayAlerts = True 27 End Sub
其实主要是这句:
1 ThisWorkbook.SaveAs "c:\1.xlsx", xlOpenXMLWorkbook
程序中清除控件、清除条件格式、清除有效性的代码,可以借鉴。