我正在尝试创建一个按钮,用自己的工作表中的一个特定单元格的名称保存我的工作簿。
我从中获取名称的单元格每周都会更改其值。 我收到错误消息:
Run-time error '1004':
Method 'SaveAs' of object'_Workbook' failed
代码如下:
Private Sub Save_file_Click()
Dim path As String
Dim filename1 As String
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets("Fejlregistrering")
path = "C:\Users\JOHLA\Desktop\Yield ark\"
filename1 = ws.Range("D5").Text
ActiveWorkbook.SaveAs path & filename1 & ".xlsm", FileFormat = xlOpenXMLWorkbookMacroEnabled
End Sub
//约翰
答案 0 :(得分:1)
更改
ActiveWorkbook.SaveAs path & filename1 & ".xlsm", FileFormat = xlOpenXMLWorkbookMacroEnabled
到
ActiveWorkbook.SaveAs Filename:=(path & filename1 & ".xlsm"), FileFormat:=xlOpenXMLWorkbookMacroEnabled
答案 1 :(得分:0)
尝试以下
ActiveWorkbook.SaveAs Filename:=path & filename1, FileFormat:=xlOpenXMLWorkbookMacroEnabled