|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Exclude code of my applicationMy problem is when the user don't have Excel, I would like exclude the code that use excel inside my code, because this make me a fatal crash. How I make that?. For example, I have the next code: '------------- Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load 'OTHER CODE HERE try Dim m_Excel As new Excel.Application Working_excel(folder_sel, "", m_Excel) 'Function inside other module. Catch ex As Exception End Try End Sub End Class '-------------- Thanks in advance for any help. Freddy Coal "Freddy Coal" <freddycoal@gmaiwithoutspam.com> wrote in Aren't you doing any exception handling?news:ON3soRUMIHA.484@TK2MSFTNGP06.phx.gbl: > Hi, My application have some modules that use Excel like a external > program. My problem is when the user don't have Excel, I would like > exclude the code that use excel inside my code, because this make me a > fatal crash. How I make that?. i.e. check if the object was successfully created then continue? -- I see that you already have an Exception handler in the code snippet that
you posted. Does this error throw up as soon as you try to run the application. Cos, the refernce to the Excel library will first have to pass in order for the application to start and execute. Sort of like Early binding. The other option would be to late bind. But let us know where/at what stage you see the exception. Regards, Trevor Benedict MCSD Show quoteHide quote "Freddy Coal" <freddycoal@gmaiwithoutspam.com> wrote in message news:ON3soRUMIHA.484@TK2MSFTNGP06.phx.gbl... > Hi, My application have some modules that use Excel like a external > program. My problem is when the user don't have Excel, I would like > exclude the code that use excel inside my code, because this make me a > fatal crash. How I make that?. > > For example, I have the next code: > > '------------- > Imports Excel = Microsoft.Office.Interop.Excel > > Public Class Form1 > Private Sub Form1_Load(ByVal sender As System.Object, _ > ByVal e As System.EventArgs) Handles MyBase.Load > > 'OTHER CODE HERE > try > Dim m_Excel As new Excel.Application > Working_excel(folder_sel, "", m_Excel) 'Function inside other > module. > Catch ex As Exception > End Try > End Sub > End Class > '-------------- > > Thanks in advance for any help. > > Freddy Coal > Well Trevor, the exception exist when the client don't have Excel; The fail
is general, the program don't start if not found Excel. EventType: clr20r3 P9: system.invalidoperationexception The system crash the program, and send the error to Microsoft; My question is how exclude the code when I know that user don't have Excel, because a Try Catch don't work in this case. Thanks in advance for any help. Freddy Coal Show quoteHide quote "Trevor Benedict" <TrevorN***@yahoo.com> wrote in message news:OagPcJVMIHA.4196@TK2MSFTNGP04.phx.gbl... >I see that you already have an Exception handler in the code snippet that >you posted. > > Does this error throw up as soon as you try to run the application. Cos, > the refernce to the Excel library will first have to pass in order for the > application to start and execute. Sort of like Early binding. The other > option would be to late bind. But let us know where/at what stage you see > the exception. > > Regards, > > Trevor Benedict > MCSD > > "Freddy Coal" <freddycoal@gmaiwithoutspam.com> wrote in message > news:ON3soRUMIHA.484@TK2MSFTNGP06.phx.gbl... >> Hi, My application have some modules that use Excel like a external >> program. My problem is when the user don't have Excel, I would like >> exclude the code that use excel inside my code, because this make me a >> fatal crash. How I make that?. >> >> For example, I have the next code: >> >> '------------- >> Imports Excel = Microsoft.Office.Interop.Excel >> >> Public Class Form1 >> Private Sub Form1_Load(ByVal sender As System.Object, _ >> ByVal e As System.EventArgs) Handles MyBase.Load >> >> 'OTHER CODE HERE >> try >> Dim m_Excel As new Excel.Application >> Working_excel(folder_sel, "", m_Excel) 'Function inside other >> module. >> Catch ex As Exception >> End Try >> End Sub >> End Class >> '-------------- >> >> Thanks in advance for any help. >> >> Freddy Coal Freddy,
Here is an example of Late Binding. If you have any questions ask. http://support.microsoft.com/kb/302902 http://www.c-sharpcorner.com/UploadFile/psingh/CallingCOMComponentFromCSharp12022005231615PM/CallingCOMComponentFromCSharp.aspx HTH Regards, Trevor Benedict MCSD Show quoteHide quote "Freddy Coal" <freddycoal@gmaiwithoutspam.com> wrote in message news:eQV$NLfMIHA.1204@TK2MSFTNGP03.phx.gbl... > Well Trevor, the exception exist when the client don't have Excel; The > fail is general, the program don't start if not found Excel. > > EventType: clr20r3 > P9: system.invalidoperationexception > > The system crash the program, and send the error to Microsoft; My question > is how exclude the code when I know that user don't have Excel, because a > Try Catch don't work in this case. > > Thanks in advance for any help. > > Freddy Coal Create a test project to test this out and also remove the reference to the
Excel PIA. Regards, Trevor Benedict MCSD Show quoteHide quote "Trevor Benedict" <TrevorN***@yahoo.com> wrote in message news:e1H0RzgMIHA.6060@TK2MSFTNGP05.phx.gbl... > Freddy, > Here is an example of Late Binding. If you have any questions ask. > > http://support.microsoft.com/kb/302902 > http://www.c-sharpcorner.com/UploadFile/psingh/CallingCOMComponentFromCSharp12022005231615PM/CallingCOMComponentFromCSharp.aspx > > HTH > > Regards, > > Trevor Benedict > MCSD > set a import to Microsoft.Win32 at the top of your class
Imports Microsoft.Win32 Function IsExcelInstalled() As Boolean Dim regClasses As RegistryKey = Registry.ClassesRoot Dim regExcel As RegistryKey = regClasses.OpenSubKey("Excel.Application") If regExcel Is Nothing Then IsExcelInstalled = False Else IsExcelInstalled = True End If regExcel.Close() End Function now before you do your excel stuff you first check if Excel is installed with the above function if IsExcelInstalled then 'do your excel stuff here else msgbox ("Nag blah Excel not installed on your system blah need to reformat PC blah bla nag :-) " end if Well i guess you get the idea :-) HTH Michel Posseth Show quoteHide quote "Freddy Coal" <freddycoal@gmaiwithoutspam.com> schreef in bericht news:ON3soRUMIHA.484@TK2MSFTNGP06.phx.gbl... > Hi, My application have some modules that use Excel like a external > program. My problem is when the user don't have Excel, I would like > exclude the code that use excel inside my code, because this make me a > fatal crash. How I make that?. > > For example, I have the next code: > > '------------- > Imports Excel = Microsoft.Office.Interop.Excel > > Public Class Form1 > Private Sub Form1_Load(ByVal sender As System.Object, _ > ByVal e As System.EventArgs) Handles MyBase.Load > > 'OTHER CODE HERE > try > Dim m_Excel As new Excel.Application > Working_excel(folder_sel, "", m_Excel) 'Function inside other > module. > Catch ex As Exception > End Try > End Sub > End Class > '-------------- > > Thanks in advance for any help. > > Freddy Coal >
sort two arrays as one?
Copying files with progress bar How to stop disabled text boxes being greyed out VB2008 changes? Vb.Net/SQL slowdown Call HTML control in code behind (ASP.net 2.0) Visual Studio 2005: VB fill circle automatic Kill explorer process and disable it restart automatically Problem Using VB.net Class Library DLL in VBScript [VB2008] How to replace lines in a textfile? |
|||||||||||||||||||||||