PDA

View Full Version : VBA to reset list box and check boxes



kjacob318
03-10-2016, 09:28 AM
Hello, I am trying to write a maco that will help clear a form that I created. I have most of it but am getting stuck trying to clear a list box and uncheck all checkboxes. Below is the code I have.

What I need help with is clearing the "Plant" listbox and unchecking the check boxes Receive, RMA, BER and Other. I have two options I've tried and nothing is working! Does anyone have any idea to help make this work?


ActiveDocument.SelectContentControlsByTitle("Date of Submission")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("MDN/DSN")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("Plant")(1).SetPlaceholderText , , "Choose an item." ' I want to be able to reset this to the default value
ActiveDocument.SelectContentControlsByTitle("Bin Location")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("CPN/MPN")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("PO/RO #")(1).Range.Delete

ActiveDocument.SelectContentControlsByTitle("Receive")(1).SetUncheckedSymbol
ActiveDocument.FormFields("RMA").CheckBox.Value = False
ActiveDocument.FormFields("BER").CheckBox.Value = False
ActiveDocument.FormFields("Other").CheckBox.Value = False

gmaxey
03-10-2016, 01:26 PM
Hello, I am trying to write a maco that will help clear a form that I created. I have most of it but am getting stuck trying to clear a list box and uncheck all checkboxes. Below is the code I have.

What I need help with is clearing the "Plant" listbox and unchecking the check boxes Receive, RMA, BER and Other. I have two options I've tried and nothing is working! Does anyone have any idea to help make this work?


ActiveDocument.SelectContentControlsByTitle("Date of Submission")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("MDN/DSN")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("Plant")(1).SetPlaceholderText , , "Choose an item." ' I want to be able to reset this to the default value
ActiveDocument.SelectContentControlsByTitle("Bin Location")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("CPN/MPN")(1).Range.Delete
ActiveDocument.SelectContentControlsByTitle("PO/RO #")(1).Range.Delete

ActiveDocument.SelectContentControlsByTitle("Receive")(1).SetUncheckedSymbol
ActiveDocument.FormFields("RMA").CheckBox.Value = False
ActiveDocument.FormFields("BER").CheckBox.Value = False
ActiveDocument.FormFields("Other").CheckBox.Value = False

gmaxey
03-10-2016, 01:28 PM
.dropdownlistentries.item(1).select

.checked = False

kjacob318
03-10-2016, 02:29 PM
Thank you, Greg! I was able to get the drop down list to work perfectly! However, I'm still unable to get the checkbox to uncheck. With the code below, I'm getting "invalid parameter". The checkbox name is "Receive"


ActiveDocument.ContentControls.item("Receive").Checked = False

gmaxey
03-10-2016, 03:09 PM
Thank you, Greg! I was able to get the drop down list to work perfectly! However, I'm still unable to get the checkbox to uncheck. With the code below, I'm getting "invalid parameter". The checkbox name is "Receive"


ActiveDocument.ContentControls.item("Receive").Checked = False

ActiveDocument.SelectContentControlByTitle("Recieve").Item(1).Checked.Value = False

kjacob318
03-10-2016, 03:38 PM
Unfortunately still running into an issue. Showing error "Compile error: Invalid qualifier"


ActiveDocument.SelectContentControlsByTitle("Receive").item(1).Checked.Value = False

gmaxey
03-10-2016, 03:45 PM
Unfortunately still running into an issue. Showing error "Compile error: Invalid qualifier"


ActiveDocument.SelectContentControlsByTitle("Receive").item(1).Checked.Value = False

pecking this out on cell phone. There is a typo in the statement. It is Control not Controls.