LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default SheetChange event crashes using Range.set_value (C#)



Hi

i have a serious problem while i was working in Excel.I want to fetch
columns from an excel worksheet and i need to compare it with an sql
querry fields,so i tried to open an excle worksheet first..


Unfortunately my code was throwing error like


CLSID\{00020819-0000-0000-C000-000000000046} IS NOT VALID OR NOT
REGISTERED.
But the same exe is working fine in other Pc's except mine.Then i
overcome the error with the code


Dim oldCI As System.Globalization.CultureInfo =
System.Threading.Thread.CurrentThread.CurrentCultu re
System.Threading.Thread.CurrentThread.CurrentCultu re = New
System.Globalization.CultureInfo("en-US")


after that excel sheet was opening but i cant read the rows or columns
in it
error throws like "Old format or Invalid Type Library" in the
particular statement wherever i used worksheet.methodname


Here i put the entire code


please help me


Imports System.Windows.Forms
Imports Microsoft.Office.Core
Imports Excel
Public Class Form1
Inherits System.Windows.Forms.Form
Public xlApp As New Excel.Application


Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click


Try


Dim strFileName As String
Dim intRows, intCols As Integer
Dim r, c As Integer
Dim Strquerry As String
Dim strpos As Integer
Dim strposc As String
Dim StrMid As String
'Create a dialog box to find the excel file


Dim dlg As New OpenFileDialog
dlg.Filter = "Excel Files (*.xls)|*.xls"
dlg.FilterIndex = 0
dlg.ShowDialog()
strFileName = dlg.FileName


Dim oldCI As System.Globalization.CultureInfo =
System.Threading.Thread.CurrentThread.CurrentCultu re
System.Threading.Thread.CurrentThread.CurrentCultu re = New
System.Globalization.CultureInfo("en-US")


Dim xlWB As Excel.Workbook
xlWB = xlApp.Workbooks.Open(strFileName)
TextBox1.Text = strFileName
xlWB.Application.Visible = True


System.Threading.Thread.CurrentThread.CurrentCultu re = oldCI


Dim xls As Excel.Sheets
Dim xlsheet As New Excel.Worksheet


xls = xlWB.Worksheets


xlsheet = CType(xls.Item(1), Excel.Worksheet)
xlsheet.activate()


intRows = xlsheet.UsedRange.Rows.Count
If intRows < 0 Then
intCols = xlsheet.UsedRange.Columns.Count
If intCols < 0 Then


' Scroll through all the rows and columns retrieving values.
For r = 1 To intRows
For c = 1 To intCols
Strquerry = TextBox2.Text
strpos = InStr(1, Strquerry, "(")
strposc = InStr(strpos, Strquerry, ",")
StrMid = Mid(Strquerry, strpos, CType(xlsheet.Cells(r, c),
Excel.Range).Text)
StrMid = Mid(Strquerry, strposc, CType(xlsheet.Cells(r, c),
Excel.Range).Text)
MsgBox(StrMid)
Next
Next


xlWB.Close(False)
xlApp.Quit()
xls = Nothing
xlWB = Nothing
xlApp = Nothing
End If


End If
Catch ex As Exception
MsgBox(ex.Message)
End Try


End Sub


End Class


thanks in advance
Dimple




*** Sent via Developersdex http://www.developersdex.com ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SheetChange event restore old value Anton Sommer Excel Programming 1 August 8th 05 10:36 PM
How to know what caused SheetChange event.. Srini Excel Programming 0 April 26th 05 11:22 PM
how to handle 'sheetchange' event on 'add-in' Takoyaki Excel Programming 2 December 19th 04 04:50 AM
SheetChange Event Tom Ogilvy Excel Programming 0 November 23rd 04 07:10 PM
SheetChange Event crispbd[_34_] Excel Programming 0 November 23rd 04 06:43 PM


All times are GMT +1. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"