Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dave
 
Posts: n/a
Default Macro to delete a text box and copy in new one

I need to set-up a macro to go from one file, file1, into another file,
file2, and delete a text box in file2. Then, I need the macro to go back
into file1 and copy a blank text box over to file2 and put it in the same
location. Is this possible? Any information is appreciated.

Thanks
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You could do it with something like:

Option Explicit
Sub testme()

Dim fWks As Worksheet
Dim tWks As Worksheet
Dim fShape As Shape
Dim tShape As Shape
Dim tLocation As Range

Set fWks = Workbooks("book1.xls").Worksheets("sheet1")
Set tWks = Workbooks("book2.xls").Worksheets("sheet1")

Set fShape = fWks.Shapes("textbox1")
Set tShape = tWks.Shapes("textbox1")

Set tLocation = tShape.TopLeftCell
Application.Goto tLocation

tShape.Delete
fShape.Copy
tWks.Paste

End Sub

But it sounds like just clearing that textbox would be equivalent.

Option Explicit
Sub testme2()
Dim tWks As Worksheet
Dim tShape As Shape

Set tWks = Workbooks("book2.xls").Worksheets("sheet1")
Set tShape = tWks.Shapes("textbox1")

tShape.OLEFormat.Object.Object.Value = ""

End Sub

I used textboxes from the control toolbox toolbar placed on worksheets.

Dave wrote:

I need to set-up a macro to go from one file, file1, into another file,
file2, and delete a text box in file2. Then, I need the macro to go back
into file1 and copy a blank text box over to file2 and put it in the same
location. Is this possible? Any information is appreciated.

Thanks


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"