PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Thomas Bock on June 26, 2018, 01:38:07 AM

Title: search installed Excel
Post by: Thomas Bock on June 26, 2018, 01:38:07 AM
Hello List ... oops ... Everyone

Currently we're looking for an installed Excel with
call "[LCL]*win/registry", err = *next, "HKEY_CLASSES_ROOT", "Excel.Application\CurVer", $$, dummy$

This doesn't work for an installed Excel-App.
Looking for a registered extension with
call "[LCL]*win/registry", err = *next, "HKEY_CLASSES_ROOT", "SystemFileAssociations\.xls\shellex", $$, dummy$
is not a possitive replacememt, because OpenOfficeCalc may have registered it.

Does someone know a way how to figure out an installed Excel-App?

Regards
Title: Re: search installed Excel
Post by: Mike King on June 26, 2018, 08:32:51 AM
Funny you should ask about this.  We are in the middle of adding a similar check to a PxPlus utility due to recent changes in Windows 10.

The logic we are testing is:

Code: [Select]
call "[lcl]*win/registry;read",err=*next,"hkey_classes_root","excel","",_X$;
        if _X$<>"" then print "Excel Installed"

So far in our limited testing this appears to work.
Title: Re: search installed Excel
Post by: Thomas Bock on June 26, 2018, 09:55:35 AM
That doesn't work here. Neither on the Surface Book (Excel-App), nor on my desktop (Excel 365). We're using PxPlus V14 SCS. Both throw an error 11.
Title: Re: search installed Excel
Post by: Mike King on June 26, 2018, 10:43:51 AM
Perhaps it is using the 64 Bit version of Excel and since PxPlus is a 32 Bit application the system is checking the 32 bit registry.

The registry accesses may need to be changed to:

call "[lcl]*win/registry;read",err=*next,"hkey_classes_root","excel","",_X$,0,64

The issue of different registries was mentioned in a Topic in the FAQ in the Knowledge base section
https://forum1.pvxplus.com/index.php?topic=22.0 (https://forum1.pvxplus.com/index.php?topic=22.0)
Title: Re: search installed Excel
Post by: Thomas Bock on June 26, 2018, 11:01:07 AM
That doesn't work either. There is simply no entry hkey_classes_root\excel, but there are very much entries hkey_classes_root\excel.<something>.
Title: Re: search installed Excel
Post by: Mike King on June 26, 2018, 04:22:09 PM
You may have to contact Microsoft to have them advise how to tell if Excel-App is installed.  Its really not something relative to PxPlus but rather to Windows and how it registers applications.
While the Apps is likely in the C:\Program Files\WindowsApps directory -- this won't help you much as this directory cannot be accessed without Admin privileges.

There may also be a registry entry somewhere but as you are dealing with "Apps" on Windows they may be using some other form of registration process as Apps are installed quite differently than normal windows applications.

Now you might be able to use powershell to get a list of apps installed by executing:

powershell -Command get-appxpackage
That will give you a ton of output but you may be able to scan for Excel-App.

Title: Re: search installed Excel
Post by: Cedric on July 11, 2018, 01:52:00 PM
Why not just try to open an Excel object?  If it fails, Excel isn't available?

while 1
  ExcelAvailable=0
  def object EXCEL,"[WDX]Excel.Application",err=*break
  delete object EXCEL,err=*next
  ExcelAvailable=1
  break
wend
Title: Re: search installed Excel
Post by: Thomas Bock on July 12, 2018, 01:43:31 AM
That was our first approach in the past. But it turned out, that this creates an Excel object thus eating time. And in worse cases the installation process starts. We just want to look for the availability of Excel in order to disable/enable import and export options.
Strange enough, though the call to *win/registry fails, a def object EXCEL,"[WDX]Excel.Application" works on both systems.
Title: Re: search installed Excel
Post by: Mike King on July 12, 2018, 10:32:03 AM
This sounds like you are over reaching in trying to disable the export to EXCEL if it is not installed.  There are MANY program that can read EXCEL files and many that can create them. 

Here is a link to page that names but a few.
https://www.lifewire.com/what-is-an-xlsx-file-2622540

Unless you plan to test for all of these, suppressing the import/export could potentially cause problems for clients that don't want/need to have a fully functional EXCEL and are using some of these alternatives.

BTW: On my MAC I have iWork and when I run Windows under Parallels, I can use iWork to open and edit any XLSX file.