nzeser
05-04-2012, 06:39 AM
I'm new to using VBA in the MS Word environment. What I have are some MS Word documents that are protected (formatting and editing are restricted). I can disable that feature, but don't know if that will have to be considered when running a macro or not. Within the documents are a sets of instructions for users to follow and most of the user feedback involves a list box with three values ("", "PASS", or "FAIL") defaulted to the blank option. Since the length of each document can vary and the number of list boxes can vary as well, I'd like to approach my task with a generic macro that can apply to all documents. At the bottom of the document I'd like to insert a button that does the following:
1) Count the total number of list boxes within the document
2) Cycle through those list boxes and check their value
3) If the value = "" then change it to "PASS", else if the value = "PASS" or "FAIL" then skip.
The documents can be 100 to 200 pages long and it can take too long to fill in while trying pay attention to events going on around you...this would provide the user a quick way to only document what they determine to be "FAIL" and at the end populate the unpopulated list boxes instead of having to go back through and manually update them.
My thoughts are to use a for loop to count the number of list boxes and populate an integer with that value (int_ListBoxCount), then another for loop to cycle through 1 to int_ListBoxCount with a If statement comparing and looking for the three values. First, I don't know how to count list boxes and second I don't know how to jump from list box to list box updating their values. Additionally, will the macro have to disable to document protection in order to run properly? Any advice/direction would be greatly appreciated, thanks!
1) Count the total number of list boxes within the document
2) Cycle through those list boxes and check their value
3) If the value = "" then change it to "PASS", else if the value = "PASS" or "FAIL" then skip.
The documents can be 100 to 200 pages long and it can take too long to fill in while trying pay attention to events going on around you...this would provide the user a quick way to only document what they determine to be "FAIL" and at the end populate the unpopulated list boxes instead of having to go back through and manually update them.
My thoughts are to use a for loop to count the number of list boxes and populate an integer with that value (int_ListBoxCount), then another for loop to cycle through 1 to int_ListBoxCount with a If statement comparing and looking for the three values. First, I don't know how to count list boxes and second I don't know how to jump from list box to list box updating their values. Additionally, will the macro have to disable to document protection in order to run properly? Any advice/direction would be greatly appreciated, thanks!