Hi,
I'm working with VB 6 and Ms Excel. My Excel Workbook has 3 worksheets.
I want to retrieve data from one of the sheets and show it in my Flexgrid, but I don't know how to select a spesific sheet.
I've wrote this code so far:
Please help.
Nairda
I'm working with VB 6 and Ms Excel. My Excel Workbook has 3 worksheets.
I want to retrieve data from one of the sheets and show it in my Flexgrid, but I don't know how to select a spesific sheet.
I've wrote this code so far:
Code:
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Private Sub Command1_Click()
Set xlapp = New Excel.Application
Set xlbook = xlapp.Workbooks.Open("C:\XLTAB.xls")
XL
End Sub
Code:
Private Sub XL()
Clipboard.Clear
With xlapp.ActiveWorkbook.ActiveSheet '------> I think I miss something here
.Range("A2:K284").Copy
End With
With MSHFlexGrid1
.Redraw = False
.Row = 3
.Col = 2
.RowSel = MSHFlexGrid1.Rows - 1
.ColSel = MSHFlexGrid1.Cols - 1
.Clip = Replace(Clipboard.GetText, vbNewLine, vbCr)
.Col = 1
.Redraw = True
End With
xlapp.DisplayAlerts = False
xlbook.Close
xlapp.Application.Quit
Set xlbook = Nothing
Set xlapp = Nothing
End Sub
Nairda
Comment