我将如何摆脱此错误消息?

时间:2019-01-30 06:46:37

标签: excel vba

我想问一下如何消除此错误通知?请看所附图片。

我正在使用此VBA代码:

  Sub Sample()
'~~> Change Sheet1 to the relevant sheet
'~~> This will create a new workbook with the relevant sheet
ThisWorkbook.Sheets("Fuels_Slips_Issued").Copy

'~~> Save the new workbook
ActiveWorkbook.SaveAs "C:\book1.xlm", FileFormat:=xlOpenXMLWorkbook
 End Sub

This a screen grab with the error code

1 个答案:

答案 0 :(得分:1)

XLM不是FileFormat:= xlOpenXMLWorkbook。忽略扩展名,并让FileFormat参数添加正确的扩展名。

ActiveWorkbook.SaveAs Filename:="C:\book1", FileFormat:=xlOpenXMLWorkbook 'XLSX type

有关FileFormat类型的完整列表,请参见xlFileFormat enumeration