writing to Excel ?

rangerbud249

Active member
Joined
Aug 18, 2004
Messages
27
Programming Experience
Beginner
hello,

I am trying to write to an Excel sheet some information.
on sheet 1 I would like names
on sheet 2 I would like addressess
How can I save information on sheet2, sheet3, and so on.

I used this but it only goes up to sheet 3 and I need more than 3 sheets:

<
Dim app As New Excel.Application
app.Visible =
True
Dim name As String
name = "Fleet_Material_Station_Consumption"
Dim doc As Excel.Workbook = app.Workbooks.Open("C:\Temp\" & Path.GetFileNameWithoutExtension(name) & ".xls")
ed1 += 1
Dim sheet As Excel.Worksheet = doc.Sheets(ed1)
>

thanks


 
Excel Workbook starts with 3 sheets

You will need to add new worksheets if the worksheet is not available. A new excel Workbook starts out with sheets 1-3.

'Creating Excel Worksheet
Dim WSheet As New Excel.Worksheet
'Adding new worksheet to excel workbooks
WSheet = EXL.Workbooks.Add.Worksheets.Add ' CType(EXL.Workbooks.Add.Worksheets.Add, Excel.Worksheet)

Something along those lines...
 
Back
Top