Hi
I am running sql which prompts the user to select the directory where they want to save the result.
It worked when I had it as csv, but when I change it to be xlsx as below, I get the error "Excel cannot open the file 'filename.xlsx' because the file format for the file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Is this because it's reading it as a text file?
Thanks
I am running sql which prompts the user to select the directory where they want to save the result.
It worked when I had it as csv, but when I change it to be xlsx as below, I get the error "Excel cannot open the file 'filename.xlsx' because the file format for the file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
Is this because it's reading it as a text file?
Code:
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
strSaveFileAs = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY, _
DialogTitle:="Save Xlsx")
If strSaveFileAs <> "" Then
strStartDateF = DTPicker1
strEndDateF = DTPicker2
StrRoute = cboRoute
StrDelayCode = cboDelaycode
If cboRoute.text = "(All Routes)" Then
cboRoute = "%"
End If
If cboDelaycode.text = "(All Codes)" Then
cboDelaycode = "%"
End If
strStartDateF = Format(strStartDateF, "MM/DD/YYYY")
strEndDateF = Format(strEndDateF, "MM/DD/YYYY")
'Set connection
MyConn = DBFullName
intFileNumber = FreeFile
Open strSaveFileAs For Output As #intFileNumber
Thanks