Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Russell Hill
  Where is Russell Hill?
 Sydney
 Australia
 Russell Hill
 Tags
Subject: RE: Please help convert macro code to vfp
Thread ID: 289088 Message ID: 289134 # Views: 31 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Tuesday, December 28, 2010 3:56:35 PM         
   


> >
> >
> >
> > WITH oExcel && Where oExcel is your Excel.Application instance
> >     .Sheets.Add()
> >     .Sheets("Sheet4").Select
> >     .Sheets("Sheet4").Move(null,.Sheets(4))
> > ENDWITH
> > 

> > (not tested)
> > -----------------
> > Borislav Borissov
> >
> > Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
> > The only thing normal about database guys is their tables.
>
> For future reference, how did you do that? Do you have a technique for converting all the non-trivial macros to VFP for automation?

and here is how I do it (I believe you need to have Excel VBA help in your reach and have some idea about the object model):

-Put a dot before the object. Here Sheets. You need to know its parent. Since Sheets is a member of both the application (Excel itself) and workbook object you can choose to use one of them. My preference is:

with oExcel.ActiveWorkbook
 .Sheets(...


-Then for methods add the parentheses.
-Add the parameters in their positional order ( named parameters is not supported in VFP:( ) omitting the ones that you wouldn't use different from the default.
-and in particular cases like Sheets.Move() you need to know that you cannot simply omit the first parameter as you do with other functions but need to use NULL. Unfortunately that bit of info is not available in help (maybe there is depending on how careful one in interpretation) but via forums and experience only.

In summary, excel automation code is mostly try and fail and then pray that it wouldn't break with the next Excel version:)

Cetin Basoz

.Net has got better.Think about moving - check my blog:
Blog (main)
Blog (mirror)

ENTIRE THREAD

Please help convert macro code to vfp Posted by Bert Murillo @ 12/28/2010 9:54:12 AM
RE: Please help convert macro code to vfp Posted by Borislav Borissov @ 12/28/2010 10:06:39 AM
RE: Please help convert macro code to vfp Posted by Bert Murillo @ 12/28/2010 10:54:09 AM
RE: Please help convert macro code to vfp Posted by Russell Hill @ 12/28/2010 12:53:21 PM
RE: Please help convert macro code to vfp Posted by Russell Hill @ 12/28/2010 12:55:18 PM
RE: Please help convert macro code to vfp Posted by Samir H. @ 12/28/2010 1:20:43 PM
RE: Please help convert macro code to vfp Posted by Borislav Borissov @ 12/28/2010 1:31:25 PM
RE: Please help convert macro code to vfp Posted by Cetin Basoz @ 12/28/2010 3:56:35 PM
RE: Please help convert macro code to vfp Posted by Russell Hill @ 12/28/2010 8:54:32 PM