Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy and paste

Status
Not open for further replies.

IPOMonkey

Programmer
Jun 18, 2003
163
GB
I want to copy information in an excel spreadsheet one column at a time simply by using CTRL C.
I then want to paste this information into text boxes on a form.

Can it be done?

 
you could do somthing like this
Code:
Dim Sheet1 as object
Dim StrVal as string
dim i as long

set sheet1 = createobject("excel.application")
sheet1.workbooks.add
sheet1.workbooks.open filename:="c:\your.xls"

for i = 1 to 10
StrVal  = sheet1.range("A" & i)
textbox1(i-1) = strval
next i

sheet1.activewindow.close
sheet1.quit
set sheet1 = nothing
[\code]
 
Why not use FormName.Text = Clipboard.GetText method?
 
if i use:

Private Sub Command1_Click()
For A = 0 To 100
Text1(A).Text = Clipboard.GetText
Next A
End Sub

All text boxes get the same text rather than each text box getting only a line of text.

 
If I'm understanding it correctly, you are selecting an entire column, then you want to paste it to your program so each cell ends up in a different text box - is that correct?

If so, then you will have to parse the cell values from the clipboard individually. Excel saves each cell with a tab between them and a carriage return at the end of each row. I'm not sure if a single column only has a carriage return separator. If that's the case, you could use the split function, then index through the array and store in your text boxes.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top