Jump to content

Recommended Posts

Posted

Over at CodeProject.com, someone posted this C++ code for testing whether Word is installed:

Type officeType = Type.GetTypeFromProgID("Word.Application");

if (officeType == null)
{
    // Word is not installed.
    // Show message or alert that Word is not installed.
}
else
{
    // Word is installed.
    // Continue your work.
}

I've been trying to figure out to do this in AutoIt, preferably using the COM interface, but I haven't managed at all. Does anyone know the quick answer to this problem?

Posted

Normally use '' for InunoTaishou second solution like so:

$hOffice = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\winword.exe", "")
If FileExists($hOffice) = 0 Then Exit

However if you're coding for multiple versions of Office I normally  use this:

$hOffice_Version = 0
$hOffice = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\winword.exe", "")
If FileExists($hOffice) Then $hOffice_Version = Round(FileGetVersion($hOffice), 0)
Switch $hOffice_Version
    Case 12
        ;~ Office 2007 Code here
    Case 14
        ;~ Office 2010 Code here
    Case 15
        ;~ Office 2013 Code here
    Case 16
        ;~ Office 2016 Code here
    Case Else
        ;~ Office not detected or unknown version
EndSwitch

 

Posted
  On 1/1/2017 at 10:39 PM, Subz said:

Normally use '' for InunoTaishou second solution like so:

$hOffice = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\winword.exe", "")
If FileExists($hOffice) = 0 Then Exit

However if you're coding for multiple versions of Office I normally  use this:

$hOffice_Version = 0
$hOffice = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\winword.exe", "")
If FileExists($hOffice) Then $hOffice_Version = Round(FileGetVersion($hOffice), 0)
Switch $hOffice_Version
    Case 12
        ;~ Office 2007 Code here
    Case 14
        ;~ Office 2010 Code here
    Case 15
        ;~ Office 2013 Code here
    Case 16
        ;~ Office 2016 Code here
    Case Else
        ;~ Office not detected or unknown version
EndSwitch

 

Expand  

That's very useful - thank you.  The second one shows me how to test for ancient versions that may not work with the procedures I'm using. Thank you again.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...