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
"Freddy Coal" <fr********@gmaiwithoutspam.comschreef in bericht
news:ON*************@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