Wilder1626
asked on
VB6- Copy a row from excel and paste it in Text2 VB6 issue
Hello all
I'm trying to copy a row from an excel file and paste it in my VB6 project in a Text2 as multiline but i have a hard time with it.
I'm trying this way:
But i have this run time error 91.
How can i fix this please?
Thanks again for your help
I'm trying to copy a row from an excel file and paste it in my VB6 project in a Text2 as multiline but i have a hard time with it.
I'm trying this way:
If Text2 <> "" Then
MsgBox "Data already in Textbox"
Else
Dim varData
If Selection.Rows.Count > 1 Then
varData = Join(Application.Transpose(Selection.Value), vbCr)
ElseIf Selection.Columns.Count > 1 Then
varData = Join(Application.Transpose(Application.Transpose(Selection.Value)), vbCr)
Else
varData = Selection.Value
End If
With Me.Text2
.Text = varData
End With
End If
But i have this run time error 91.
How can i fix this please?
Thanks again for your help
ASKER
Hi Rgonzo1971
Well the textbox is in a VB6 form and not in Excel.
The texbox name is Text2.
Thanks
Well the textbox is in a VB6 form and not in Excel.
The texbox name is Text2.
Thanks
ASKER
I have also tried like this but it past everything on 1 row
Private Sub test1_Click()
Dim sText As String
sText = Clipboard.GetText
Text2.Text = Trim(Replace(sText, vbTab, vbCrLf))
End Sub
the runtime error 91 means "object not set" ...
on which line? on which variable?
while stepping through the code, it should become obvious
on which line? on which variable?
while stepping through the code, it should become obvious
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi angelIII
Yes, the Text2 is set to be Multiline but still pasting on the same row using that code bellow:
Yes, the Text2 is set to be Multiline but still pasting on the same row using that code bellow:
Private Sub test1_Click()
Dim sText As String
sText = Clipboard.GetText
Text2.Text = Trim(Replace(sText, vbTab, vbCrLf))
End Sub
ASKER
I think i had a issue with the textbox itself.
I deleted that textbox and created a new one and called it Text3 with a Multiline yes and now it work with :
I deleted that textbox and created a new one and called it Text3 with a Multiline yes and now it work with :
Private Sub test1_Click()
Dim sText As String
sText = Clipboard.GetText
Text3.Text = Trim(Replace(sText, vbTab, vbCrLf))
End Sub
good :)
ASKER
Thanks again for your help
all good now
all good now
Shouldn't you refer to TextBox2 on line 12
Regards