473,471 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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.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
Nov 27 '07 #1
4 1139
"Freddy Coal" <fr********@gmaiwithoutspam.comwrote in
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?.
Aren't you doing any exception handling?

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

--
Nov 27 '07 #2

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

Nov 28 '07 #3
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/UploadF...romCSharp.aspx

HTH

Regards,

Trevor Benedict
MCSD

"Freddy Coal" <fr********@gmaiwithoutspam.comwrote in message
news:eQ**************@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

Nov 28 '07 #4
Create a test project to test this out and also remove the reference to the
Excel PIA.

Regards,

Trevor Benedict
MCSD

"Trevor Benedict" <Tr********@yahoo.comwrote in message
news:e1**************@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/UploadF...romCSharp.aspx

HTH

Regards,

Trevor Benedict
MCSD

Nov 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rajesh Abraham | last post by:
I would like to Exclude MyApp.Exe.Config from my Setup Package as I don't want it to get overwritten during upgrade installation of my application. If I remove app.config while building the...
4
by: Maxim | last post by:
Greetings, In my C# project, I'm using a third-party Opensource library... in source code form. I mean no assemblies, just pure source code. It allows me to add new application-specific...
4
by: Brad | last post by:
I'm not one to rant or flame....so please excuse me while I do so for this once. I've now spent a bit of time working with VS2005 beta 2 to see how it functions for web development, especially how...
9
by: paul.jameson | last post by:
I have a simple Access database that stores Karaoke Songlists for my local pub. From this you are able to print out the song lists they use. Up until now, any duplicate songs that appear on say,...
2
by: Arsen V. | last post by:
Hi, How to exclude the App_Data directory from Visual SourceSafe? It appears that Vs 2005 automatically adds the App_Data directory with the large binary MDF and LOG files to the Visual...
3
by: KJ | last post by:
Hello All, Can someone please explain what these .exclude/.include files are? They only show up in some web site projects, and it seems to be related to deleting. Any ideas?
1
by: AntiChrist | last post by:
In VS 2005 if you exclude files from a project, it actually renames the file to filename.exclude. In previous versions, it just left the file alone but excluded it. If you have a very large...
0
by: =?Utf-8?B?a2V2aW4=?= | last post by:
using VS2005, web application projects, web deployment projects My web installer builds from the output of the web deployment project. I end up with the obj folder in my web site. How do I use...
3
by: ITSimTech | last post by:
I'm trying to learn how/do two things here: 1) If the user searches for "Data" ($searchtext = "Data") the output should also include the fourth record because Field1 contains "all". 2) But the...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.