PDA

View Full Version : hiding objects



talytech
03-30-2012, 04:09 AM
Hello,

I would like to know if its possible to hide controls on a word document? I have a document with some text boxes on them. The text boxes are from the control toolbox. I want to be able to hide the text boxes when the document is open, then when I click a button, I want to unhide the text boxes. Can that be done? Or only on a userform can you control the objects via code?

fumei
03-30-2012, 04:40 AM
Oh you can control things...however, there is no .Hide, nor .Visible. So, no, you can not hide a control.

BUT, you can change the size. So have your Document_Open make the control small, and have your button change the height and width. Put the code in the ThisDocument module so you can use the Properties of the control directly.Option Explicit

Private Sub Document_Open()
TextBox1.Height = 1
TextBox1.Width = 1
End Sub

Private Sub CommandButton1_Click()
TextBox1.Height = 17.8
TextBox1.Width = 72
End Sub

talytech
03-30-2012, 06:10 AM
Hi! Thanks alot!!! :) That worked perfectly.

fumei
03-30-2012, 09:15 AM
Good. Please mark the thread as Solved.