moving/copying text boxes

eds000

Board Regular
Joined
Dec 11, 2006
Messages
76
I have a text box (253) from the DRAW menu which contains 3 lines (warning message) which is deleted if the user enables the macro when opening the file

I need to put the textbox in the same position on the sheet when the user closes the file so whenever the user opens the file they are forced to enable the marco.

I tried using the text box in the control box but I can't control it and I need to have the text box containing 3 lines of data. Any easy way of doing this?
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You might be able to save yourself some trouble if you make the text box invisible rather than deleting it.

Code:
ActiveSheet.Shapes("Text Box 253").Visible = False 'Change text box name as required.

ActiveSheet.Shapes("Text Box 253").Visible = True 'Change text box name as required.


If you want the text box to appear in exactly the same place between sessions you will have to record its position when the book is closed or put it in the correct position before the book is closed (and saved). There are a number of ways you could store its position.

You could use something like the following to make sure the text box is at least visible if the exact position is not required.

Gary

Code:
Public Sub Test()

Dim sAddress As String
Dim oTextBox As Shape

'Roughly center of visible range
sAddress = ActiveWindow.VisibleRange.Cells(ActiveWindow.VisibleRange.Cells.Count / 2).Address

'Instead of above, calculate top left of text box using window size.
'MsgBox ActiveWindow.Height
'MsgBox ActiveWindow.Width

Set oTextBox = ActiveSheet.Shapes("Text Box 1")

oTextBox.Left = ActiveSheet.Range(sAddress).Left
oTextBox.Top = ActiveSheet.Range(sAddress).Top
        
oTextBox.Visible = msoTrue
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top