Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controlling Excel from within VFP
Message
De
12/12/2001 14:18:23
 
 
À
12/12/2001 13:58:53
Kam Lee
SUNY-Health Science Center
Brooklyn, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00593112
Message ID:
00593434
Vues:
26
>>>Hi all,
>>>
>>>Where can I find a complete obect model for MS Excel? I like to manipulate
>>>Excel from within VFP like opening an existing spreading sheet, retrieving
>>>cells' value and etc...
>>>
>>>Or anybody can give a few pinters to get me started ?
>>>
>>>Thanks.
>>>
>>>Kam.
>>
>>What I usually do is save a macro in Excel, for whatever I plan to do (say, bold, borders, change column width, etc.). The commands can then easily be adapted to VFP.
>>
>>The following primitive sample may help you get started:
>>
>>
>>oExcel = CreateObject("Excel.Application")
>>oExcel.Visible = 1   && for debugging
>>oExcel.Workbooks.Add()
>>oSheet = oExcel.ActiveSheet
>>oSheet.Cells(1,1) = "Hello!"
>>
>>
>>Afterwards, use the "macro" approach.
>>
>>HTH, Hilmar.
>
>Hi Hilmar,
>
>Thanks for the tip. By any chance you know how to open an existing Excel
>worksheet ?
>
>Thanks again.
>
>Kam.

The techniques for gathering that info are important.

Make sure VBA for Excel is loaded. Open up a VBA macro and you'll have access to the full object model in VBA help.

To get a sense of what commands are needed, create a macro, do the operation, then open up the macro. You'll see VBA commands which can be converted fairly straightforwardly to VFP.

The one piece you don't get here is the constants which are passed to the various Excel methods. I believe there's a file here at UT which provides the Excel VBA constants. VFP won't understand the constants unless you #DEFINE them or use variables and assign them the appropriate value.

Jay
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform