15,912,756 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by arpita aradhya (Top 2 by date)
arpita aradhya
23-Nov-16 6:27am
View
I have improved the code and edit the code in the post. Now I have error at line xlFile_WB = xlappFile.Workbooks(destination1). system nullreferenceexception object reference not set
arpita aradhya
23-Nov-16 5:42am
View
Deleted
Hi,
I have added all that but it does not identify lookin, lookwhole like inb excel
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
Dim xlappFile As Excel.Application = Nothing
Dim xlFile_WB As Excel.Workbook = Nothing
Dim xlFile_WS As Excel.Worksheet = Nothing
Dim xlFirstfile_WS1 As Excel.Worksheet = Nothing
Dim FoundRange As Excel.Range
Dim searchID As String
searchID = Textbox1.Text
Try
xlFile_WB = xlappFile.Workbooks(destination1) ' destination1 is selected by 'user
xlFile_WS = xlappFile.Worksheets(1)
FoundRange = xlFile_WS.Cells.Find(What:=searchID, LookIn:=xlFormulas, LookAt:=xlWhole)
If FoundRange Is Nothing Then
textbox2.Text = "not found"
textbox3.Text = "not found"
textbox4.Text = "not found"
textbox5.Text = "not found"
textbox6.Text = "not found"
Else
textbox2.Text = FoundRange.Offset(0, 2).Value
textbox3.Text = FoundRange.Offset(0, 3).Value
textbox4.Text = FoundRange.Offset(0, 4).Value
textbox5.Text = FoundRange.Offset(0, 5).Value
textbox6.Text = FoundRange.Offset(0, 6).Value
End If
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Me.Close()
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
ReleaseObject(xlFile_WS)
xlFile_WB.Close(SaveChanges:=False)
ReleaseObject(xlFile_WB)
xlappFile.Quit()
ReleaseObject(xlappFile)
End Try
End Sub
Private Sub ReleaseObject(ByVal ob As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(ob)
Catch
Finally
ob = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Sub