Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
Please consider this code ...
'wb_classcsv' is opened as a .csv file.
WIth the lines in blue, I create a new worksheet in workbook 'wb_classcsv' and name it 'stats' and set ws_stats to to it.
The red line saves the file with a name of (example) "Jun-24 (Mon).xlsx".
I am running into two problems...
1) The tab I named 'stats' is changing to 'Jun-24 (Mon)' with the saving of this file for some reason I cannot explain. This will cause problems for me down the road, I cannot allow this tab to be renamed to anything other than 'stats'
2) I cannot open this newly created file. I get the error "Excel cannot open the file 'Jun-24 (Mon).xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Please, can anyone help?
Rich (BB code):
With wb_classcsv
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Stats"
Set ws_stats = .Worksheets("Stats")
With ws_stats
.Range("A3") = "Date: "
.Range("B3") = Format(usr_date, "dd-mmm-yy")
.Range("C3") = Format(usr_date, "00000")
.Range("A4") = "Created: "
.Range("B4") = Format(Now, "dd-mmm-yy")
.Range("C4") = Format(Now, "h:mm:ss am/pm")
.Cells.EntireColumn.AutoFit
End With
fname = Format(usr_date, "mmm-dd (ddd)") & " Data.xlsx"
stname = "U:\PWS\Parks\Parks Operations\Sports\WATSOP19\DATA\" & fname
Application.DisplayAlerts = False
.SaveAs Filename:=stname
Application.DisplayAlerts = True
End With
'wb_classcsv' is opened as a .csv file.
WIth the lines in blue, I create a new worksheet in workbook 'wb_classcsv' and name it 'stats' and set ws_stats to to it.
The red line saves the file with a name of (example) "Jun-24 (Mon).xlsx".
I am running into two problems...
1) The tab I named 'stats' is changing to 'Jun-24 (Mon)' with the saving of this file for some reason I cannot explain. This will cause problems for me down the road, I cannot allow this tab to be renamed to anything other than 'stats'
2) I cannot open this newly created file. I get the error "Excel cannot open the file 'Jun-24 (Mon).xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Please, can anyone help?