Hi guys, im trying to do the reallly simple task of setting some textboxes to visible = false, but word is hating it!
It just dosnt seem to be an option in word 2002
Can anyone help?
Many thanks. :thanx: :thanx:
Hi guys, im trying to do the reallly simple task of setting some textboxes to visible = false, but word is hating it!
It just dosnt seem to be an option in word 2002
Can anyone help?
Many thanks. :thanx: :thanx:
Re: Word cannot have TextBox1.visible = false???
Hi,
Bit short on details. Where is this textbox in relation to the document? Is it an active-x control on the document, or maybe a formfield or perhaps a userform textbox?
Can you post an example file, which might clarify things?
Re: Word cannot have TextBox1.visible = false???
Hi,
Its just a VB control, a textbox
I've attached a file, but added a command button to click
In VB, it would just be: "TextBox1.Visible = False"
But in vba in word that doesnt work. It works fine in excel, but not word.
Thanks for your help.
Regards.
Re: Word cannot have TextBox1.visible = false???
Hi,
The controls do not appear to have a Visible property. Go to design mode and select either the textbox or commandbutton. If you display the properties window Visible is not listed.
How about using the Enabled property instead?
Re: Word cannot have TextBox1.visible = false???
No, enabled is no good.
If the .visible is available in excel, why not word?
Im sure someone will give a solution.
Thanks again.
Re: Word cannot have TextBox1.visible = false???
Hello,
Try this code below
You can not really make the box disappear, unless you wrote code to erase it, but this will allow it to stay out of your way. At most, the tab key would take you to it, but you wouldn't be able to type in it. A mouse click on it would also put the cursor there, but again you wouldn't be able to type in it
Private Sub CommandButton1_Click()
TextBox1.Value = "" 'Gets rid of any text the user typed in textbox1 box
TextBox1.SpecialEffect = 0 'makes flat, rather than sunken by default.
TextBox1.BorderStyle = 0 'Gets rid of single line border around textbox1 box
TextBox1.BackColor = &HFFFFFF 'makes box a white background - not really necessary
TextBox1.Locked = True 'Locks box, to prevent user from typing in it
TextBox1.TabKeyBehavior = False 'when user presses tab, it will still stop at this textbox
'but they will not be able to type anything in, however
'what is important is that pressing tab again will take
'them to the next textbox on the screen, if set to True
'the cursor will be stuck at this point, and only the mouse
'will be able to move the cursor to a new location on the screen
'TextBox1.HideSelection = doesn't matter 'this property setting has nothing to do with visible or not
'its for keeping a selection highlighted or not when the
'control has the focus or not. See the help files
'TextBox1.visible = false '.visible is not a valid property setting for MS Word objects.
End Sub
Display More
Re: Word cannot have TextBox1.visible = false???
Another quick example:
Sometimes you want the box to be visible and sometimes you don't.
For instance, in the example below, when the user selects "Other" in a ComboBox1, then TextBox1 becomes visible. The user can also go back and select something else in ComboBox1, and TextBox1 will disappear.
Private Sub ComboBox1_Change()
'If user selects "Other" then TextBox1 becomes visible on the screen.
'It is intended that the user type in what corresponds to "Other" item in TextBox1
If ComboBox1.Value = "Other" Then '"Other" is one of the selections from a drop
'down list present when clicking on ComboBox1
TextBox1.Value = "Please type in" 'instructs user to type in TextBox1
TextBox1.BackColor = &H80FFFF 'Highlights TextBox1 in yellow to alert
'user to type in it - this is optional code
TextBox1.SpecialEffect = 1 'makes TextBox1 appear sunken into screen
TextBox1.BorderStyle = 1 'Puts single line border around TextBox1
TextBox1.Locked = False 'unlocks TextBox1, which is usually locked,
'so user can type in it.
Else 'If user selects a selection other than "Other",
'or changed their mind after typing in text.
TextBox1.Value = "" 'Gets rid of any text the user may have
'typed in TextBox1
TextBox1.BackColor = &HFFFFFF 'Returns box to white color to make it
'blend back into white page
TextBox1.SpecialEffect = 0 'flat, not sunken in
TextBox1.BorderStyle = 0 'Gets rid of Single Line border around TextBox1
TextBox1.Locked = True 'Locks TextBox1, to prevent user from typing in it
End If
End Sub
Display More
Re: Word cannot have TextBox1.visible = false???
Thanks for all your help everyone!
What i was basicly trying to do was have a textbox visible, then hide it soon as the document loaded.
That way, if macros were disabled, the user would see the textbox with instructions on how to turn macros on. Once this was done, the code to hide the textbox would be able to run, and it wouldnt be seen.
Cheers all. :thanx:
Re: Word cannot have TextBox1.visible = false???
you're welcome!
Ok so i had the exact same issue never coded in my life, but this worked for me.
Hope this helps
Private Sub CheckBox4_Change()
'If user selects "Other" then TextBox4 becomes visible on the screen.
'It is intended that the user type in what corresponds to "Other" item in TextBox4
If CheckBox4.Value = "True" Then '"Other" is one of the selections from a drop
'down list present when clicking on CommandButton1
TextBox4.Value = "Please type in" 'instructs user to type in TextBox4
TextBox4.BackColor = &H80FFFF 'Highlights TextBox4 in yellow to alert
'user to type in it - this is optional code
TextBox4.SpecialEffect = 1 'makes TextBox4 appear sunken into screen
TextBox4.BorderStyle = 1 'Puts single line border around TextBox4
TextBox4.Locked = False 'unlocks TextBox4, which is usually locked,
'so user can type in it.
Else 'If user selects a selection other than "Other",
'or changed their mind after typing in text.
TextBox4.Value = "" 'Gets rid of any text the user may have
'typed in TextBox4
TextBox4.BackColor = &HFFFFFF 'Returns box to white color to make it
'blend back into white page
TextBox4.SpecialEffect = 0 'flat, not sunken in
TextBox4.BorderStyle = 0 'Gets rid of Single Line border around TextBox4
TextBox4.Locked = True 'Locks TextBox4, to prevent user from typing in it
End If
End Sub
Don’t have an account yet? Register yourself now and be a part of our community!