Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Population an Excel Range with an array
Message
From
06/07/2013 16:02:43
 
 
To
06/07/2013 14:50:37
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01577886
Message ID:
01577889
Views:
62
This message has been marked as a message which has helped to the initial question of the thread.
Here is one option. It's might not be exactly what you are looking for but perhaps useful. It converts the array into a string and pastes it into the cell range required.
CLEAR ALL
DIMENSION saNames(5,2)
saNames[1, 1] = "John"
saNames[1, 2] = "Smith"
saNames[2, 1] = "Tom"
saNames[2, 2] = "Brown"
saNames[3, 1] = "Sue"
saNames[3, 2] = "Thomas"
saNames[4, 1] = "Jane"
saNames[4, 2] = "Jones"
saNames[5, 1] = "Adam"
saNames[5, 2] = "Johnson"
oExcel = CREATEOBJECT("Excel.Application")
oExcel.Visible = .T.
oBook =  oExcel.Workbooks.Add()
oBook.Sheets[1].Name = "Summary"

WITH oExcel.ActiveSheet
  .Range["A1"].Value = "First"
  .Range["B1"].Value = "Last"
 * oRange = .Range["A2:B6"]   // Not required in this option
ENDWITH

* Convert the array into a tab delimited string. Each line ends in CR.
tstr_to_paste = ""
FOR I = 1 TO 5
  tstr_to_paste = m.tstr_to_paste + saNames[I, 1] + CHR(9) + saNames[I, 2] + CHR(13)
NEXT

* Copy the string to paste to the clipoard
_cliptext = tstr_to_paste

* Select the starting cell for the paste operation
oExcel.ActiveSheet.Range("A2").select

* Paste the clipboard to Excel
oExcel.ActiveSheet.Paste
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform