0
フォルダにExcelブックを保存するためのvbaコードを作成しました。しかし、私は実行時エラー1004を取得しています。すでに存在するファイルが開かれ、同じExcelブックも作成されます。ファイルを保存すると、既存のファイルがすでに開いているとエラーが発生します
Private Sub CommandButton14_Click()
Dim folderpath As String
Dim Fname As String
Dim file As String
Fname = MyForm.SCC.Value
folderpath = ActiveWorkbook.Path
Workbooks.Open Filename:= _
("" & folderpath & "\" & Fname & "- Q3 2016" & ".xlsx")
' for adding explaination sheet from PAM sheet into destination sheet
' Section E: please update the name of excel workbook if the name of this excel workbook changed
Windows("OEM PAM Sizer 2016 - v1.xlsm").Activate
Sheets("Automation Content definition").Visible = True
Sheets("Automation Content definition").Select
Sheets("Automation Content definition").Copy After:=Workbooks(_
"" & Fname & "- Q3 2016" & ".xlsx").Sheets(1)
ActiveWorkbook.Worksheets("sheet1").Activate
Range("a1").Select
file = "" & folderpath & "\" & Fname & "- Q3 2016" & ".xlsx"
FileExist (file)
Windows("OEM PAM Sizer 2016 - v1.xlsm").Close savechanges:=False
End sub