Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Move cursor in Excel
Message
From
15/11/2006 11:51:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/11/2006 11:16:55
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01169625
Message ID:
01169934
Views:
7
>>>>>I know I've asked this question before but I can't seem to find any reference to the answer.
>>>>>Suppose you have a spreadsheet open in excel, how do you move the cursor to the right or left?
>>>>>
>>>>>oExcel.Range('A2').select
>>>>>oExcel.ActiveCell.value = crsChart.year
>>>>>
>>>>>oExcel.MoveRight
>>>>>
>>>>>
>>>>>etc.
>>>>>
>>>>>
>>>>>Thanks
>>>>
>>>>
>>>>oExcel = CREATEOBJECT('Excel.Application')
>>>>WITH oExcel
>>>> .Workbooks.Add
>>>> .Visible = .t.
>>>> .ActiveWorkbook.ActiveSheet.Range('A2').select
>>>> .ActiveCell.Value = 2006
>>>> .ActiveCell.Offset(0,1).Select
>>>>endwith
>>>>
Cetin
>>>
>>>Thanks Cetin
>>>That's twice you've answered this for me. I'll do a better job of filing this time.
>>>- Don
>>
>>Who really does a filing for such small things anyway:) I don't.
>>PS: You said you would "loop" and I suspect you're doing an unnecessary loop. I can't know w/o details though.
>>Cetin
>
>Here's my loop code
>
>oExcel.range("A2").select
>scan
>   oExcel.ActiveCell.value = crsChart.year
>   oExcel.ActiveCell.Offset(0,1).Activate
>   oExcel.ActiveCell.value = crsChart.AMU
>   oExcel.ActiveCell.Offset(0,1).Activate
>   oExcel.ActiveCell.value = crsChart.Goal
>   oExcel.ActiveCell.Offset(1,-2).Activate
>endscan
>
>
>- Don
oExcel.range("A2").select
scan
   oExcel.ActiveCell.value = crsChart.year
   oExcel.ActiveCell.Offset(0,1).value = crsChart.AMU
   oExcel.ActiveCell.Offset(0,2).value = crsChart.Goal
   oExcel.ActiveCell.Offset(1,0).Activate
endscan
However this just makes you feel better:) Would run slow (just imagine with hundreths - not even thousands- of rows).
There are N different ways to transfer this type of data from VFP to Excel in one shot. Here is one:
select Year,AMU,Goal from crsChart into array aMyData

oExcel = createobject('excel.application')
with oExcel
  .WorkBooks.Add
  .Visible = .t.
  WITH .ActiveWorkBook.ActiveSheet
     .Range( .Cells(2,1), .Cells(2-1+ALEN(aMyData,1),1-1+ALEN(aMyData,2))).Value = getArrayRef('aMyData')
  endwith
ENDWITH

FUNCTION getArrayRef(tcArrayName)
RETURN @&tcArrayName
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform