Results 1 to 7 of 7

Thread: How to check if word , excel ,access or any office application is Installed ??

  1. #1

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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:
    1. Dim TargetKey As RegistryKey
    2.         TargetKey = Registry.ClassesRoot.OpenSubKey("word.application")
    3.         If TargetKey Is Nothing Then
    4.             MsgBox("Word application is not found")
    5.         Else    'key is found
    6.             MsgBox("Word application is found")
    7.             TargetKey.Close()
    8.         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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. Private bInstalled As Boolean
    2.  
    3. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Try
    5.             Dim oApp As Object = CreateObject("Outlook.Application")
    6.             bInstalled = True
    7.         Catch
    8.             bInstalled = False
    9.             MessageBox.Show("Office Application not installed!", "Office Installed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    10.         End Try
    11. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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


  6. #6
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    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!

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width