Throubles with Visual Basic and Excel
Hi, i use this code to send all data in a msflexgrid to an excel worksheet:
Private Sub cmdExcel_Click() Dim AppEx As Excel.Application Dim AreaLibroex As Excel.Workbook Dim AreaHojaEx As Excel.Worksheet Dim I As Integer, J As Integer 'Darle valores a los objetos excel Set AppEx = CreateObject("excel.application") Set AreaLibroex = AppEx.Workbooks.Add Set AreaHojaEx = AreaLibroex.Worksheets(1) 'Recorrer el grid y pasar los valores a cada celda de la hoja de excel prgBar.Max = grid.Rows - 1 For I = 0 To grid.Rows - 1 prgBar.Value = I For J = 0 To grid.Cols - 1 AreaHojaEx.Cells(I + 1, J + 1) = grid.TextMatrix(I, J) Next Next prgBar.Value = 0 prgBar.Max = 100 AppEx.Visible = True Set AppEx = Nothing Set AreaLibroex = Nothing Set AreaHojaEx = Nothing End Sub but, my throuble comes when one of the celd in the grid is a date, the convertion is bad. For example, if the celd says "01/12/04", in excel it appears like "12/01/04", the werid thing is that, that only happens with dates where month day. I use the "dd/mm/yy" format. it works like this: msflexgrid - excel 01/12/04 - 12/01/04 02/12/04 - 12/02/04 03/12/04 - 12/03/04 .... 11/12/04 - 12/11/04 12/12/04 - 12/12/04 13/12/04 - 13/12/04 this is true for all months. I tried a lot of things but nothing seems to work... please please please help me!! Sorry if my english is not so good, Matias. |
Try going into windows Control Panel, date and time and set the short date
to "dd/mm/yy" HTH Ken |
All times are GMT +1. The time now is 03:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com