Hi
I am exporting data from my VB app to Excel named ranges using the CopyFromRecordSet function. The data comes over - but the numbers are changed to dates! I added the folowing code to explicitly set the format - it does not throw any error nor does it work. I've been splitting my hair over this for the past couple of days with the deadline looming!
For jCol = 0 To rs.Fields.Count - 1
Select Case rs.Fields(jCol).Type
Case ADODB.DataTypeEnum.adInteger, ADODB.DataTypeEnum.adUnsignedInt, ADODB.DataTypeEnum.adBigInt, ADODB.DataTypeEnum.adSmallInt, ADODB.DataTypeEnum.adUnsignedTinyInt, ADODB.DataTypeEnum.adUnsignedSmallInt
namedRange.Columns(jCol).NumberFormat = "#,##0"
'Case ADODB.DataTypeEnum.adDate, ADODB.DataTypeEnum.adDBDate
' namedRange.Columns(jCol).numberformat = "m/d/yyyy;@"
End Select
Next
I am exporting data from my VB app to Excel named ranges using the CopyFromRecordSet function. The data comes over - but the numbers are changed to dates! I added the folowing code to explicitly set the format - it does not throw any error nor does it work. I've been splitting my hair over this for the past couple of days with the deadline looming!
For jCol = 0 To rs.Fields.Count - 1
Select Case rs.Fields(jCol).Type
Case ADODB.DataTypeEnum.adInteger, ADODB.DataTypeEnum.adUnsignedInt, ADODB.DataTypeEnum.adBigInt, ADODB.DataTypeEnum.adSmallInt, ADODB.DataTypeEnum.adUnsignedTinyInt, ADODB.DataTypeEnum.adUnsignedSmallInt
namedRange.Columns(jCol).NumberFormat = "#,##0"
'Case ADODB.DataTypeEnum.adDate, ADODB.DataTypeEnum.adDBDate
' namedRange.Columns(jCol).numberformat = "m/d/yyyy;@"
End Select
Next