Ok, I may be in over my head. Here is the concept of what I am attempting, but failing, to do.
I have a UserForm that has 6 toggle buttons and a command button. Each toggle button corresponds to one of the possible sections in the document, which are the words passed to GetDocRange as startWord and endWord. The idea is to click the toggle buttons for the sections that are in a given document and then click the command button to close the UserForm and continue with execution of the macro.
Based on which toggle buttons are set to true, corresponding variables should be set to true. Based on the values of those variables, startWord and endWord should be provided. For example, the possible sections as represented by the toggle buttons are Background, Summary, Drawing, Description, Claim, and Abstract.
If all sections are present, the code should progress through a first loop with startWord = Background and endWord = Summary, a second loop with startWord = Summary and endWord = Drawing, etc. When startWord is Abstract, endWord should also be Abstract.
However, if all sections are not present, that section should be skipped. For example, assume that Summary is not present in some given document. In that case, the toggle buttons for all sections other than Summary are toggled true and the code should progress through a first loop with startWord = Background and endWord = Drawing, a second loop with startWord = Drawing and endWord = Description, etc. When startWord is Abstract, endWord should again be Abstract.
I have ToggleButtonX_Change routines for each toggle button in the UserForm that chack whether the button value is true or false, but I'm having trouble figuring out where to stick the variables (and what type they should be) for the loop, as well as figuring out how to set up the loop to do the skips as I described. My thought is some sort of For loop with the index used for the table number as well as selecting which of the section names to use for startWord and endWord, but that's a half-baked thought that I can't seem to round out into an outline for coding. The second thought was combining the For loop and index with a select case statement to evaluate the various possible outcomes, but that thought didn't get much farther than the first. I'm open to any suggestions or advice, and thanks in advance.
|