Copy an array to clipboard
I hav an array MyArray
I want to copy the content of this array to clipboard, so that it can then be pasted to an excel file..
can any one help me
thnx in advance..
This is a new one for me but I don't think the Clipboard object accepts complex types. Since Excel accepts CSV transparently, you could loop through your array building a comma delimited list, and then copy that to the Clipboard object.
for i = 0 to len(myArray)
myListFromArray = myListFromArray & ',' & myArray(i)
Managing Technical Editor
MyString = Join(MyArray, vbKeyTab) & vbNewLine
Can't solve the issue
Thnx guys for d reply..
usually i copy the rows in a string and paste it to clipboard
But my actual problem is .. ihave a grid with more than 15,000 rows..
since its is large to hold in a string i created a string array and copy the data to it..
but i cannot copy this to clipboard
i tried another method, select the entire grid and copy to clipboard
grid.Col = 0
grid.row = 0
grid.ColSel = grid.Cols - 1
grid.RowSel = grid.Rows - 1
but here also i have a problem.. i dont need all columns some should hide..
is there any method to select som specified columns..
grid means MSHFlexGrid
Once on the clipboard, what will you do with it?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Why go to the clipboard.
You can communicate directly with Excel.
First add a reference to Excel in the project properties Reference tab.
Working with Excel is then pretty easy with code similar to the following:
Dim app As Excel.Application
Dim wks as Excel.Worksheet
'Excel is invisible by default
'Excel does not create an empty workbook when started by programmation
'Reference the first sheet
'Do whatever you want
A couple of loops will let you transfer the data, controlling what goes and what does not, even modify it before the transfer.
And you still have a contact with Excel (app), the workbook (app.Workbooks(1) or the worksheet(wks) to do any manipulation you want such as saving the file or adding formulas.
I knw direct interaction with excel is better.. but the user wants the data in clipboard, so that he can copy it in any excel worksheet.
Can anyone help me to to solve the above listed 2 problems..
Send it to Excel, and then Copy to the clipboard from Excel.
Since the copy is made from Excel, it will be in the right format for pasting.
Hi i was trying to just this however i how found a nice easy Native Code Way to copy grid data to clipboard
all i did was copy from a grid then paste in to the following code
This then listed in the debug windows each char in Ascii
For i = 1 to Len(ClipText)
debug.print "asc-" & Asc(Mid$(ClipText,i,1)) & " - Char - " & Mid$(ClipText,i,1)
This let me see that the copied data was Tab Delimited with CRLF end of each line
therefore this follow code works great
Then You can easly just paste the data to excel, textboxs, or other grids
For i = 1 To MyGrid.Rows - 1 'From First DataRow (first row has titles)
'Check For Empty Cells
If Grid1.Cell(i, 1).Text <> "" And Grid1.Cell(i, 3).Text Then
'Add To MyString as "TAB delimited
'CR and LF For Newline "Chr(13) & Chr(10)"
MyString = MyString & Grid1.Cell(i, 1).Text & Chr(9) & Grid1.Cell(i, 2).Text & Chr(13) & Chr(10)
I'm using FlexCell Grid, so the code to get the data from the grid maybe differant for you
I Do Realise this is a Old Post however i figured someone will get some help from this
Last edited by Hack; 06-21-2012 at 06:49 AM.
Reason: Added Code Tags
Last Post: 05-27-2008, 11:17 AM
Last Post: 12-22-2006, 05:51 AM
By triley35 in forum .NET
Last Post: 04-03-2006, 11:55 PM
By Michael Bourns in forum VB Classic
Last Post: 10-26-2000, 06:58 PM
By Michael Bourns in forum VB Classic
Last Post: 10-25-2000, 09:56 PM
Tags for this Thread
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL