|
-
Aug 26th, 2005, 07:55 PM
#1
Thread Starter
Frenzied Member
How to check if word , excel ,access or any office application is Installed ??
first of all you must import namespace [ microsoft.win32] to access the registery classes in .net framwork
then this code will check the regestery if the application is installed or not
VB Code:
Dim TargetKey As RegistryKey
TargetKey = Registry.ClassesRoot.OpenSubKey("word.application")
If TargetKey Is Nothing Then
MsgBox("Word application is not found")
Else 'key is found
MsgBox("Word application is found")
TargetKey.Close()
End If
you can change the string in the second line from "word.application" to "excel.application" or "access.application" in order to check for different components.
rgds
-
Aug 26th, 2005, 08:08 PM
#2
Re: How to check if word , excel ,access or any office application is Installed ??
You could also test for it without having to work around any possible user permissions to the reqistry by just error trapping the creation of an object of the type your testing for.

VB Code:
Private bInstalled As Boolean
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim oApp As Object = CreateObject("Outlook.Application")
bInstalled = True
Catch
bInstalled = False
MessageBox.Show("Office Application not installed!", "Office Installed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 26th, 2005, 08:50 PM
#3
Thread Starter
Frenzied Member
Re: How to check if word , excel ,access or any office application is Installed ??
well that is another way ,
but mine is more effecient with the drawback of required permession to access registery keys.
why it is effecient ???
because
1 - raising exceptions may take a while in processing, direct code is faster
2 - try catch statemnt is slower than direct code execution
3 - if the office application is installed, then you are creating a new instance of the application without any use. also you didn't dispose it from the memory after monitoring that it is succesffuly created.
that is all the drawbacks i can find in your code, although this method is more guranteed due to permessions required to access registery.
anyway, i am only responding to your reply because i like to urgue, but in the matter of fact you are far more experienced than me . only to the current moment, i will do my best
rgds
-
Aug 26th, 2005, 08:59 PM
#4
Re: How to check if word , excel ,access or any office application is Installed ??
Oh good, I like to argue too! Jk. I only posted another possibility because I though it may be helpful to have more then one way to skin a cat. 
With my method it has advantages over yours for similar reasons.
1. - Accessing the registry should be done in a Try Catch block to trap for registry permissions issues.
2. - Try Catch may be slower but since it is risky to directly attempt to read the registry or create and office app object both should be in a Try Catch block. 
3. - Yes, I am creating an instance of Outlook, but if your testing to see if Outlook is installed its because your going to be using it in your code or why test for it being installed.
I didnt add allot of clean up code because it was only a logic example.
You are getting better though and are catching up to me.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 26th, 2005, 10:22 PM
#5
Thread Starter
Frenzied Member
Re: How to check if word , excel ,access or any office application is Installed ??
You are getting better though and are catching up to me.
ohhhh, thank u
-
Aug 27th, 2005, 10:06 PM
#6
Fanatic Member
Re: How to check if word , excel ,access or any office application is Installed ??
This can only check if office applications are installed.It cant check any other applications right? Can it?
Godwin
Help someone else with what someone helped you! 
-
Aug 27th, 2005, 10:44 PM
#7
Re: How to check if word , excel ,access or any office application is Installed ??
With my code you would just change the one line of code with the "CreateObject("Outlook.Application")" to pass the application and type you want to test for.
VB Code:
Dim oApp As Object = CreateObject("SomeProgram.ApplicationType")
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|