vba如何清空同文件夹指定wps表格的内容

Sub 进货清空本表()
Workbooks("进货.xls").Worksheets("sheet1").Range("A2:AD60000").ClearContents
End Sub
不打开文件就错误

前面加一句workbook.open
后面加一句workbook.close true
下面的代码清空同一路径下,【进货.xls】文件的内容
Sub 进货清空本表()
Dim iPath As String, iFile As String
iPath = ThisWorkbook.Path & "\"
iFile = "进货.xls"
Workbooks.Open iPath & iFile
With ActiveWorkbook
.Worksheets("sheet1").Range("A2:AD60000").ClearContents
.Close True
End With
End Sub
温馨提示:答案为网友推荐,仅供参考
相似回答