Re: Excel And VB6 Question?
the worksheets are a collection so you need to move to the next sheet and set it as the worksheet object
rgds pete
Re: Excel And VB6 Question?
Since already you have a workbook, just add a sheet or activate the next sheet
Re: Excel And VB6 Question?
Thanks i have done that now.
Is there a quick way of loading a comma delimited file into the active work sheet?
thanks
Kev :eek2:
Re: Excel And VB6 Question?
Does this work for you?
VB Code:
Workbooks.Open "C:\PersonalContacts.csv", , , 2
Re: Excel And VB6 Question?
I don't think so.
I have an exsiting spreadsheet that I open, add a new worksheet and make that worksheet active. I then want to place the contents of a csv file into the new worksheet. So far all I have is
Code:
objExcel.Workbooks.Open strExcelFileName
objExcel.Worksheets.Add after:=Sheets(Worksheets.Count)
objExcel.Worksheets(Worksheets.Count).Select
I tried the loading using the opentext method, but is only used for creating a new workbook.
Re: Excel And VB6 Question?
What about this then?
VB Code:
Sub ImportCSV()
Dim f As Integer
Dim s As String
Dim l() As String
Dim r As Long
r = 20
f = FreeFile
Open "C:\PersonalContacts.csv" For Input As f
While Not EOF(f)
Line Input #f, s
l = Split(s, ",")
For c = 1 To UBound(l)
Cells(r, c).Value = l(c)
Next
r = r + 1
Wend
Close f
End Sub
Re: Excel And VB6 Question?
That sort of works, it is missing the first Line and first column but I can get around that. It also is puts quotes around everything.
I'll figure it out now that you gave me a workable suggestion. Thnaks for your help.
Kev. :afrog: