本文介绍了宏仅保存活动工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,它保存了完整的工作簿.我只想保存活动的工作表.
In the below code it saves the complete workbook. I want to save only the active worksheet.
Sub sbVBS_To_SAVE_ActiveWorkbook()
ActiveWorkbook.Save
End Sub
推荐答案
将工作表复制到无位置会自动在前台创建一个新工作簿,并将工作表的副本作为新工作簿中的唯一工作表.
Copying a worksheet to no location automatically creates a new workbook in the foreground with a copy of the worksheet as the only worksheet in the new workbook.
Sub test()
worksheets("sheet3").copy
'there is now a new active workbook
with activeworkbook
'save it
.SaveAs Filename:="some file path and filename without extension", FileFormat:=xlOpenXMLWorkbook
'optionally close it
.close savechanges:=false
end with
End Sub
这篇关于宏仅保存活动工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!