How do I detect whether Excel is available on the machine?

My idea is that if it is available I will load the data from vfp into Excel
using createobject('Excel.applciation') and put the data into the cells, but
if Excel isn't available I will use 'copy to file type XLS'

Many thanks

Stephen

RE: OLE and Excel from vfp by Leemi

Leemi
Thu Aug 03 09:41:31 CDT 2006

Hi Stephen:

Well, you could use an ON ERROR to trap the error returned by
CreateObject() if Excel is not on the machine. You could also read the
registry for Excel entries. This would be more complicated.

258528 How To Read a REG_MULTI_SZ From the Registry
http://support.microsoft.com/default.aspx?scid=kb;EN-US;258528
258161 How To Read a DWORD From the Registry
http://support.microsoft.com/default.aspx?scid=kb;EN-US;258161
258556 How To Read a REG_SZ Value From the Registry
http://support.microsoft.com/default.aspx?scid=kb;EN-US;258556
265331 How To Read a REG_EXPAND_SZ Value From the Registry
http://support.microsoft.com/default.aspx?scid=kb;EN-US;265331
244675 How to use the Windows Script Host to read, write, and delete
registry keys
http://support.microsoft.com/default.aspx?scid=kb;EN-US;244675


I hope this helps.

This posting is provided "AS IS" with no warranties, and confers no rights.

Sincerely,
Microsoft FoxPro Technical Support
Lee Mitchell

*-- VFP9 HAS ARRIVED!! --*
Read about all the new features of VFP9 here:
http://msdn.microsoft.com/vfoxpro/

*--Purchase VFP 9.0 here:
http://www.microsoft.com/PRODUCTS/info/product.aspx?view=22&pcid=54787e64-52
69-4500-8bf2-3f06689f4ab3&type=ovr

Keep an eye on the product lifecycle for Visual FoxPro here:
http://support.microsoft.com/gp/lifeselectindex
- VFP5 Mainstream Support retired June 30th, 2003
- VFP6 Mainstream Support retired Sept. 30th, 2003



>How do I detect whether Excel is available on the machine?

>My idea is that if it is available I will load the data from vfp into
Excel
>using createobject('Excel.applciation') and put the data into the cells,
but
>if Excel isn't available I will use 'copy to file type XLS'

>Many thanks

>Stephen




RE: OLE and Excel from vfp by Bob

Bob
Thu Aug 03 09:49:03 CDT 2006

I read the registry with the following code

SET CLASSLIB TO registry additive
lxo = CREATEOBJECT("registry")
lsexcel = "No"
lxo.GetRegKey("", @lsexcel, "Excel.Application")
IF lsexcel = "No" then
gExcelexists = .F.
ELSE
gExcelexists = .T.
ENDIF


The ClassLib Registry is the standard Registry Class Library of VFP.

--
Regards

Bob B.


"Lee Mitchell" wrote:

> Hi Stephen:
>
> Well, you could use an ON ERROR to trap the error returned by
> CreateObject() if Excel is not on the machine. You could also read the
> registry for Excel entries. This would be more complicated.
>
> 258528 How To Read a REG_MULTI_SZ From the Registry
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258528
> 258161 How To Read a DWORD From the Registry
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258161
> 258556 How To Read a REG_SZ Value From the Registry
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258556
> 265331 How To Read a REG_EXPAND_SZ Value From the Registry
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;265331
> 244675 How to use the Windows Script Host to read, write, and delete
> registry keys
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;244675
>
>
> I hope this helps.
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> Sincerely,
> Microsoft FoxPro Technical Support
> Lee Mitchell
>
> *-- VFP9 HAS ARRIVED!! --*
> Read about all the new features of VFP9 here:
> http://msdn.microsoft.com/vfoxpro/
>
> *--Purchase VFP 9.0 here:
> http://www.microsoft.com/PRODUCTS/info/product.aspx?view=22&pcid=54787e64-52
> 69-4500-8bf2-3f06689f4ab3&type=ovr
>
> Keep an eye on the product lifecycle for Visual FoxPro here:
> http://support.microsoft.com/gp/lifeselectindex
> - VFP5 Mainstream Support retired June 30th, 2003
> - VFP6 Mainstream Support retired Sept. 30th, 2003
>
>
>
> >How do I detect whether Excel is available on the machine?
>
> >My idea is that if it is available I will load the data from vfp into
> Excel
> >using createobject('Excel.applciation') and put the data into the cells,
> but
> >if Excel isn't available I will use 'copy to file type XLS'
>
> >Many thanks
>
> >Stephen
>
>
>
>

Re: OLE and Excel from vfp by Stephen

Stephen
Thu Aug 03 13:16:16 CDT 2006

Many thanks both

Stephen

"Bob" <Bob@discussions.microsoft.com> wrote in message
news:D9006B3A-5DF1-4BC0-9EB8-B5E5C375B975@microsoft.com...
>I read the registry with the following code
>
> SET CLASSLIB TO registry additive
> lxo = CREATEOBJECT("registry")
> lsexcel = "No"
> lxo.GetRegKey("", @lsexcel, "Excel.Application")
> IF lsexcel = "No" then
> gExcelexists = .F.
> ELSE
> gExcelexists = .T.
> ENDIF
>
>
> The ClassLib Registry is the standard Registry Class Library of VFP.
>
> --
> Regards
>
> Bob B.
>
>
> "Lee Mitchell" wrote:
>
>> Hi Stephen:
>>
>> Well, you could use an ON ERROR to trap the error returned by
>> CreateObject() if Excel is not on the machine. You could also read the
>> registry for Excel entries. This would be more complicated.
>>
>> 258528 How To Read a REG_MULTI_SZ From the Registry
>> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258528
>> 258161 How To Read a DWORD From the Registry
>> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258161
>> 258556 How To Read a REG_SZ Value From the Registry
>> http://support.microsoft.com/default.aspx?scid=kb;EN-US;258556
>> 265331 How To Read a REG_EXPAND_SZ Value From the Registry
>> http://support.microsoft.com/default.aspx?scid=kb;EN-US;265331
>> 244675 How to use the Windows Script Host to read, write, and delete
>> registry keys
>> http://support.microsoft.com/default.aspx?scid=kb;EN-US;244675
>>
>>
>> I hope this helps.
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> Sincerely,
>> Microsoft FoxPro Technical Support
>> Lee Mitchell
>>
>> *-- VFP9 HAS ARRIVED!! --*
>> Read about all the new features of VFP9 here:
>> http://msdn.microsoft.com/vfoxpro/
>>
>> *--Purchase VFP 9.0 here:
>> http://www.microsoft.com/PRODUCTS/info/product.aspx?view=22&pcid=54787e64-52
>> 69-4500-8bf2-3f06689f4ab3&type=ovr
>>
>> Keep an eye on the product lifecycle for Visual FoxPro here:
>> http://support.microsoft.com/gp/lifeselectindex
>> - VFP5 Mainstream Support retired June 30th, 2003
>> - VFP6 Mainstream Support retired Sept. 30th, 2003
>>
>>
>>
>> >How do I detect whether Excel is available on the machine?
>>
>> >My idea is that if it is available I will load the data from vfp into
>> Excel
>> >using createobject('Excel.applciation') and put the data into the cells,
>> but
>> >if Excel isn't available I will use 'copy to file type XLS'
>>
>> >Many thanks
>>
>> >Stephen
>>
>>
>>
>>