PDA

View Full Version : Hide bookmark when textbox is empty



vjdb
04-17-2008, 02:11 AM
Hello everybody,

I have a userform and it is almost perfect the only thing is that I want 2 bookmarks hidden when the correspondending textboxes are empty. So when the user fills out nothing in textbox Email the bookmark in the document should be not visible and therefore doesn't take up any space on the sheet. Is there a code to achieve this? Thanks in advance :)

This is what i thought:
If txtEmail = "" Then ActiveDocument.Bookmarks("Email").hide

lucas
04-17-2008, 06:36 AM
My thoughts:
Don't take mine as the final word but I don't think you can hide the bookmark. Even if you did it would still be taking up space on the sheet, it would just not be visable. You can delete the bookmark:
ActiveDocument.Bookmarks("email").Delete

Wait and see if anyone else with more experience in Word has any ideas.

CreganTur
04-17-2008, 09:17 AM
Personally deleting bookmarks has caused problems, so I hide them.

Code:
strBookmark = "BookmarkName"
ActiveDocument.Bookmarks(strBookmark).Select
Selection.Font.Hidden = True

This selects all text that makes up the bookmark, and then hides the selection.