By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,852 Members | 860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,852 IT Pros & Developers. It's quick & easy.

How to insert data into Excel sheet from VB.NET

P: n/a
Hi

When i clicked a button, i want to insert data from
listview in VB.NET to Excel sheet.
If you know the solution either above or below is ok for
me.
I know how to insert from a textfile,but all data of
textfile inserted into only into a single cell.I want to
insert single line of text file for each cell.
I tried to insert data into Excel sheet in many ways but
it will give some error when opening the Excel sheet.

data was inserted but when opening the sheet to view the
contents it gives error like this:

"Excel sheet was already opened"
but i never opened that sheet in before.

Here is the code i tried to insert into Excel sheet:

Dim fstr, mystr As String
Dim Index1, i, j As Integer
Dim ExcelWasNotRunning As Boolean
Dim str As String
Dim xlsWB As Object
Dim xlsPath, xlsFile, xlsTab As String

xlsWB = GetObject("D:\example.xls")

xlsWB.Parent.Windows(1).Visible = True

xlsWB.Application.Worksheets(xlsTab).Cells(3, 1) =
10
xlsWB.Application.Worksheets(xlsTab).Cells(3, 2)
= "C:\pagefile"
xlsWB.Application.Worksheets(xlsTab).Cells(4, 1) =
20
xlsWB.Application.Worksheets(xlsTab).Cells(4, 2)
= "D:\pagefile"
xlsWB.Application.Worksheets(xlsTab).Cells(5, 1) =
30
xlsWB.Application.Worksheets(xlsTab).Cells(5, 2)
= "E:\pagefile"

If any one knows please give me the solution

Mamatha
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.