简体   繁体   中英

Hide command button on word doc

I have a .doc with a command button (cmdStart) which opens a form. After populating the form I click a button to close the form and populate the .doc.

I want to hide the initial cmdStart on the .doc as well when the form closes, Ive tries document.shapes(1).visible=false and cmdStart.visible=false but none seems to work.

Any ideas?

thanks (ps I cant just opne the form from the autonew, I need the cmdStart visible to begin with)

You have several options to deal with that. However, you won't be able to hide your command button but you will be able to remove it.

Removing a command button can be done by the following code:

Private Sub CommandButton1_Click()
    CommandButton1.Select
    Selection.Delete
End Sub

(Note that usually you would be able to hide text in Word by setting the font hidden, eg by calling Selection.Font.Hidden . However, this does not affect controls.)

If you deleted the button and you need it later on again you will have to re-create it. In that case it might be a good idea to mark the position of the button with a bookmark.

Another option would be to use a MACRO button field. Such a field can be inserted from the Insert Field dialog and can be used to launch a macro.

If you really wanted to "hide" the button, you could set the Height and Width to 0.75 and it's virtually gone. Then resize back to "show". I've also seen people put them inside tags and hide the tag. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM