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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why will this (Simple) code not work now??

Status
Not open for further replies.

marshman99ca

Technical User
Apr 11, 2007
13
CA
Using Office 2000, here is the code I am using which works on my laptop with Office 2007. (The textboxes are inserted textboxes not from a userform).



CODE

Option Explicit



Sub Text_Copy()

With Worksheets("Description")

Worksheets("Summary").Shapes.("TextBox3").TextFrame.Characters.Text = .Shapes("TextBox1").TextFrame.Characters.Text & " " & .Shapes("TextBox2").TextFrame.Characters.Text



End With

End Sub



I appreciate any help.
 
Any error message ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No, no error message, it just doesn't place the text in the proper textbox!!
 
Remove the highlighted dot:
Worksheets("Summary").Shapes[highlight].[/highlight]("TextBox3").TextFrame.Characters.Text = .Shapes("TextBox1").TextFrame.Characters.Text & " " & .Shapes("TextBox2").TextFrame.Characters.Text

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, that was an error in my typing skills, it isn't actually there in the real code.
 
What happens when you debug your code, eg:
Dim t1, t2
With Worksheets("Description")
t1 = .Shapes("TextBox1").TextFrame.Characters.Text
Debug.Print "t1='" & t1 & "'"
t2 = .Shapes("TextBox2").TextFrame.Characters.Text
Debug.Print "t2='" & t2 & "'"
Worksheets("Summary").Shapes.("TextBox3").TextFrame.Characters.Text = t1 & " " & t2
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
BEfore I try that, what about this.

This file is initially saved as a template (.xlt) file. This code works if I right-click and open the template and enter data, but when I just double click and open, causing it to open as an .xls file, it doesn't work.
 
OK, what is your real code and where is it located ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is the exact code,

Code:
 Option Explicit 
 
Sub Text_Copy() 
   With Worksheets("Description") Worksheets("Summary").Shapes("TextBox3").TextFrame.Characters.Text = .Shapes("TextBox1").TextFrame.Characters.Text & " " & .Shapes("TextBox2").TextFrame.Characters.Text 
   End With 
End Sub
ANd it is in a Template file, but the people that open it have open it as an .xls file.
 



Code:
Sub Text_Copy()
   With Worksheets("Description").Worksheets("Summary")
        .Shapes("TextBox3").TextFrame.Characters.Text = _
             .Shapes("TextBox1").TextFrame.Characters.Text & " " & _
             .Shapes("TextBox2").TextFrame.Characters.Text
        
   End With
End Sub

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Skip,
Thanks for your time and effort. when I run your code I get a runtime error, '438' 'Object doesn't support this property or method'. And it activates on the line of code

With Worksheets("Description").Worksheets("Summary")

Any other ideas?? Thank you again.
 
Skip,
You put me on the right track and I have it figured. Thank you very much.
By the way, I am calling the TextBox on the last page (the Summary page) "TextBox3" and it works fine.
Thanks again,
 




BTW,

Your code is NOT a COPY process. It is an ASSIGN process.

Copying objects is not the same as assigning values.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top