View Single Post
 
Old 07-31-2015, 11:23 AM
Marrick13 Marrick13 is offline Windows XP Office 2010 32bit
Competent Performer
 
Join Date: Jun 2006
Posts: 102
Marrick13 will become famous soon enough
Default Array to iterate through variables and trap blank variables

I am trying to write a macro that copies a document and then deletes sections of text in the copy that are bookmarked. The code works fine if I preset the bookmark names in an array statement, but now I am converting the code to a userform that has four checkboxes. Checking one of the three removes one bookmarked section of text and checking the 4th removes all of the sections defined by the first 3 bookmarks. (Therefore, if the checks the 4th box, the others become unchecked and the 4th is unchecked if he checks any of the first 3.)

I’ve set the array as follows, with the variables becoming the bookmark name when their checkbox values are true:

BkmarkName = Array(Cond1, Cond2, Cond3, Cond4)

However, unchecked boxes mean some of the “Cond” variables are blank, and this causes an error in the code that deletes the bookmark text. I tried an error trap. Which works sometimes but not always. I tried a statement that builds the array text to include only those variables with a length of greater than 1 but the macro doesn’t read it as an array. There must be a way to accomplish what I’m trying to do but I’m coming up with blanks. Any help is appreciated – code is attached.
Attached Files
File Type: txt Print_Exclusions.txt (992 Bytes, 13 views)
Reply With Quote