1

Topic: Record from vfp9 a macro

Please, help to translate this macro in vfp9
Selection. AutoFill Destination: = Range ("B1066:BY1066"), Type: = xlFillDefault
Range ("B1066:BY1066").Select

2

Re: Record from vfp9 a macro

mv123321;

LOCAL ii, jj, loExcel, lcPath, loWorkBook, loSheet
loExcel = CREATEOBJECT ("Excel. Application")
loExcel. DisplayAlerts =.F.
lcPath = loExcel. Path
loExcel. WorkBooks. Add ()
loWorkBook = loExcel. ActiveWorkBook
loExcel. Visible =. T.
loSheet = loWorkBook. WorkSheets (1)
loSheet. Cells (2,1).Value = 1
loSheet. Cells (3,1).Value = 2
* Actually it
loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (3,1)).AutoFill (loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (10,1)), 0)
loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (2,1)).Select ()
CANCEL

3

Re: Record from vfp9 a macro

Instead of:

loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (3,1)).AutoFill (loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (10,1)), 0)
loSheet. Range (loSheet. Cells (2,1), loSheet. Cells (2,1)).Select ()

It is possible to write simply:

loSheet. Range ("A2:A3").AutoFill (loSheet. Range ("A2:A10"), 0)
loSheet. Range ("A2").Select ()

Yes, the second function argument AutoFill (which Type: = xlFillDefault), here it is transferred as 0 (therefore as value xlFillDefault=0).
If to cling in the beginning Excel.h it would be possible to write down so:

loSheet. Range ("A2:A3").AutoFill (loSheet. Range ("A2:A10"), xlFillDefault)

4

Re: Record from vfp9 a macro

And, here still that.
In the resulted piece instead of 2 lines:

Range ("A2:A3").Select
Selection. AutoFill (Range ("A2:A10"), xlFillDefault)

It is used simply:

Range ("A2:A3").AutoFill (Range ("A2:A10"), xlFillDefault)

5

Re: Record from vfp9 a macro

EadleRus;
Thanks for a prompt reply.
But I need to move the formula in line on their all columns of all in one case 61, in other 108 (on other sheet)

6

Re: Record from vfp9 a macro

mv123321;
If the formula in cell B1066 on columns B1066:BY1066 will be somehow so:

loSheet. Range ("B1066").AutoFill (Range ("B1066:BY1066"), xlFillDefault)

loSheet is an object of sheet of the book (from my example)

7

Re: Record from vfp9 a macro

Here it:

LOCAL loExcel, loWorkBook, loSheet
loExcel = CREATEOBJECT ("Excel. Application")
loExcel. DisplayAlerts =.F.
loWorkBook = loExcel. WorkBooks. Open ("here a full path and a name of your excel-file")
loExcel. Visible =. T.
loSheet = loWorkBook. WorkSheets ("here a sheet name in an excel-file, or sheet number - but then without inverted commas")
* Actually it
loSheet. Range ("B1066").AutoFill (Range ("B1066:BY1066"), 0)
loSheet. Range ("B1066").Select ()

You can directly copy in a command window  and launch ( at first changing file name and a sheet name)

8

Re: Record from vfp9 a macro

EagleRus_;
exl. Range (exl. Cells (lrow, 2), exl. Cells (lrow, 61)).AutoFill (exl. Range (exl. Cells (lrow, 2), exl. Cells (lrow, 61)), 0)
Where here an error?
Thanks

9

Re: Record from vfp9 a macro

mv123321;
1)
exl is that?
There should be a link to object of sheet. Not on object most Excel (!)
2)
The formula which should be multiplied, in what cell?
If in exl. Cells (lrow, 2), so:

exl. Range (exl. Cells (lrow, 2), exl. Cells (lrow, 2)).AutoFill (exl. Range (exl. Cells (lrow, 2), exl. Cells (lrow, 61)), 0)
^^^

10

Re: Record from vfp9 a macro

EagleRus_;
Many thanks. Earned.