Dear all,
I have made a function to open a excel file and read the content of a column..The thing is...it works well when i create an dummy excel file...but it failed when i want to read from an existing file which contain macro functions...it sort of captures the value but it returns null ( i think it was because of the macro had not finish/started filling up the cells)..below are my code. Please help me..thanks
I have made a function to open a excel file and read the content of a column..The thing is...it works well when i create an dummy excel file...but it failed when i want to read from an existing file which contain macro functions...it sort of captures the value but it returns null ( i think it was because of the macro had not finish/started filling up the cells)..below are my code. Please help me..thanks
VB.NET:
Try
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlApp.ScreenUpdating = False
xlApp.Workbooks.Open("c:\Data.xls")
xlApp.Visible = True
xlSht = xlApp.Sheets(1)
Dim dsNewRow As DataRow
xlRng = xlSht.Cells(9, 1)
dsNewRow = ds.Tables("LINE_NUMBER").NewRow()
dsNewRow.Item("LINE_NUMBER") = xlRng.Value
ds.Tables("LINE_NUMBER").Rows.Add(dsNewRow)
dgLineNumber.Refresh()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Last edited by a moderator: