Click here to Skip to main content
15,944,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Public apExcel As Microsoft.Office.Interop.Excel.Application = DirectCast(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)

Public Sub LoadSpreadsheet(ByRef cSheetType As String)

apExcel.Workbooks.Open(strSheetName)

End Sub


sometimes apExcel is Nothing and creates NullReferenceException when trying to open
is there any way delaying or some other solution thanks..
Posted
Updated 11-Jan-12 7:27am
v2
Comments
[no name] 11-Jan-12 13:30pm    
What does this have to do with converting from VB6 to VB.NET?

Don't create the reference in a global scope. You should be creating the Excel.Application when needed and closing and disposing when not in use.
 
Share this answer
 
Comments
Tony Radu 12-Jan-12 16:56pm    
While apExcel Is Nothing
code to wait until its intialized??
End While
 
Share this answer
 
Comments
Tony Radu 13-Jan-12 12:49pm    
still not getting a solution once in 20 this error occurs any help thanks..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900