Quote:
Originally Posted by edgara
I have developed an application for extracting records from datagrid to excel. Unfortunately, when i run this application, no records were extracted. If anybody knows what is lacking in my script then please inform me. Below is my script. Thanks a lot!!!
-
-
Private Sub cmDExtract_Click()
-
-
On Error GoTo ErrorLine
-
Screen.MousePointer = vbHourglass
-
Dim xl As Object
-
Dim wb As Object
-
Dim ws As Object
-
Dim i As Long
-
Dim X As Long
-
-
Set xl = CreateObject("Excel.Application")
-
Set wb = xl.Workbooks.Add()
-
Set ws = xl.ActiveWindow.ActiveSheet
-
ws.Columns().ColumnWidth = 10
-
-
For X = 0 To DataGrid1.Row - 1
-
DataGrid1.Row = X
-
DataGrid1.Col = 1
-
For i = 1 To DataGrid1.Col
-
DataGrid1.Col = i
-
If DataGrid1.Text <> "" Then
-
ws.Cells(X, i) = DataGrid1.Text
-
ws.Cells(X, i).HorizontalAlignment = -4131
-
-
End If
-
Next
-
Next
-
xl.Visible = True
-
ErrorLine:
-
Screen.MousePointer = vbDefault
-
-
-
-
End Sub
Hey there, edgara!
Good of you to add your code in. It looks like you have not yet attempted to create a .xls file. If you have previously searched here and could not find anything, set your eyes on this:
http://www.developerfusion.co.uk/show/6072/
This should get you started. If not, please stay tuned. I cannot run anything from here just yet. Please stay tuned nonetheless, helpful members will likely see your information.
In a bit!
Dököll