Exclude code of my application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Freddy Coal

    #1

    Exclude code of my application

    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.Offic e.Interop.Excel

    Public Class Form1
    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load

    'OTHER CODE HERE
    try
    Dim m_Excel As new Excel.Applicati on
    Working_excel(f older_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


  • Spam Catcher

    #2
    Re: Exclude code of my application

    "Freddy Coal" <freddycoal@gma iwithoutspam.co mwrote in
    news:ON3soRUMIH A.484@TK2MSFTNG P06.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?.
    Aren't you doing any exception handling?

    i.e. check if the object was successfully created then continue?

    --

    Comment

    • Michel Posseth  [MCP]

      #3
      Re: Exclude code of my application


      set a import to Microsoft.Win32 at the top of your class

      Imports Microsoft.Win32



      Function IsExcelInstalle d() As Boolean
      Dim regClasses As RegistryKey = Registry.Classe sRoot
      Dim regExcel As RegistryKey =
      regClasses.Open SubKey("Excel.A pplication")
      If regExcel Is Nothing Then
      IsExcelInstalle d = False
      Else
      IsExcelInstalle d = 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 IsExcelInstalle d 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





      "Freddy Coal" <freddycoal@gma iwithoutspam.co mschreef in bericht
      news:ON3soRUMIH A.484@TK2MSFTNG P06.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.Offic e.Interop.Excel
      >
      Public Class Form1
      Private Sub Form1_Load(ByVa l sender As System.Object, _
      ByVal e As System.EventArg s) Handles MyBase.Load
      >
      'OTHER CODE HERE
      try
      Dim m_Excel As new Excel.Applicati on
      Working_excel(f older_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
      >

      Comment

      • Trevor Benedict

        #4
        Re: Exclude code of my application

        Freddy,
        Here is an example of Late Binding. If you have any questions ask.


        http://www.c-sharpcorner.com/UploadF...romCSharp.aspx

        HTH

        Regards,

        Trevor Benedict
        MCSD



        "Freddy Coal" <freddycoal@gma iwithoutspam.co mwrote in message
        news:eQV$NLfMIH A.1204@TK2MSFTN GP03.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.invalido perationexcepti on
        >
        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

        Comment

        • Trevor Benedict

          #5
          Re: Exclude code of my application

          Create a test project to test this out and also remove the reference to the
          Excel PIA.

          Regards,

          Trevor Benedict
          MCSD

          "Trevor Benedict" <TrevorNews@yah oo.comwrote in message
          news:e1H0RzgMIH A.6060@TK2MSFTN GP05.phx.gbl...
          Freddy,
          Here is an example of Late Binding. If you have any questions ask.
          >

          http://www.c-sharpcorner.com/UploadF...romCSharp.aspx
          >
          HTH
          >
          Regards,
          >
          Trevor Benedict
          MCSD
          >

          Comment

          Working...