2
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by Jx_Man
0

hmm...
i have not started do this project,
i can send datagrid value to txt file, but not to xlx ( excel ) file

i need some reference code
thanks for reply

0

Okay. This some code :
You need add reference Microsoft Excel Library.

Private Sub Command1_Click()
    Dim XcLApp     As Object
    Dim XcLWB      As Object
    Dim XcLWS      As Object
    
    Set XcLApp = CreateObject("Excel.Application")
    Set XcLWB = XcLApp.Workbooks.Add
    Set XcLWS = XcLWB.Worksheets.Add
    
    XcLWS.Range(Addres_Excel(1, 1)).Value = "Test string"
    
    XcLApp.Visible = True
    'XcLWS.PrintOut
End Sub
Public Function Addres_Excel(ByVal lng_row As Long, ByVal lng_col As Long) As String
    Dim modval As Long
    Dim strval As String
    modval = (lng_col - 1) Mod 26
    strval = Chr$(Asc("A") + modval)
    modval = ((lng_col - 1) \ 26) - 1
    If modval >= 0 Then strval = Chr$(Asc("A") + modval) & strval
    Addres_Excel = strval & lng_row
End Function
0

hmm.., thanks a lot...

how to add excel library..???

0

Wow..you even don't know how to add reference. :D
Go to Project->Reference->Microsoft Excel 12.0 Object Library

0

hehe...
i'm newbie programmer , it's my first work using vb6
i only know how to add adodb references
hehe...

thanks a lot,

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.