Hi all
I'm getting an error message when I try to open a file I created with a macro. If I click "Yes" to continue the file opens normally, but the people I work for get skittish about this kind of thing so I'd rather they didn't get an error message when I release the code on them and they are creating their own files:
The error message is:
"The file you are trying to open, 'Consolidated Tracker 22-09-14.xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
I think it's to do with the fact it's an xls file with an xlsx structure, but I looked it up and FileFormat:=51 should give me an xlsx file, and I have specified .xlsx in the Filename2 variable. What am I missing?
I'm getting an error message when I try to open a file I created with a macro. If I click "Yes" to continue the file opens normally, but the people I work for get skittish about this kind of thing so I'd rather they didn't get an error message when I release the code on them and they are creating their own files:
Code:
Filename2 = "Consolidated Tracker " & Format(Date, "dd-mm-yy") & ".xlsx"
Filepath = diaFolder.SelectedItems(1) & "\" & Filename2
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=Filepath, FileFormat:=51
Workbooks("Consolidator.xlsm").Sheets("Consolidated Tracker").Range("A1:AX" & CopyLastRow).Copy
Workbooks(Filename2).Sheets("Sheet1").Range("A1:AX" & CopyLastRow).PasteSpecial xlPasteColumnWidths
Workbooks(Filename2).Sheets("Sheet1").Range("A1:AX" & CopyLastRow).PasteSpecial xlPasteFormats
Workbooks(Filename2).Sheets("Sheet1").Range("A1:AX" & CopyLastRow).Value = Workbooks("Consolidator.xlsm").Sheets("Consolidated Tracker").Range("A1:AX" & CopyLastRow).Value
Workbooks(Filename2).Sheets("Sheet1").Name = "Consolidated Tracker " & Format(Date, "dd-mm-yy")
Workbooks(Filename2).Sheets("Sheet2").Delete
Workbooks(Filename2).Sheets("Sheet3").Delete
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=Filepath, FileFormat:=51
Application.DisplayAlerts = True
The error message is:
"The file you are trying to open, 'Consolidated Tracker 22-09-14.xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
I think it's to do with the fact it's an xls file with an xlsx structure, but I looked it up and FileFormat:=51 should give me an xlsx file, and I have specified .xlsx in the Filename2 variable. What am I missing?