-
fumei,
I appreciate so much your help! Thanks also for pushing me... I don't always get the whole point, and though I know where I am heading, I don't always understand what the best path is...
I'll try to be more specific. The strings I search for are given by the user. I don't actually know what they are, since they can be different every time. I can only say that they are actually tags that surround text. I have to find 2 sets of strings, a bit like brackets (opening tag, closing tag) and if everything seems fine (those tags are found in the correct order, i.e. if 2 opening tags are found consecutively with no closing tag in-between, they are ignored), the text is processed through another function (let's say it is highlighted and tags are deleted).
As a side note, those tags have a minimum of 2 characters each (e.g. #< and #>), but they can also be the same ones (e.g. ### and ###), in which case I only make sure I have an even number of tags within the header, to avoid processing the wrong text.
The tags are sent to the function through a string, a bit like you did with strCheck (though I found it funny that you actually don't use it in your example, but I got your point).
Now, I do love your approach, but I have a few questions/concerns with it:
- inStr is a great function indeed that I could make use of in other cases (and I certainly will), but is there a way to keep track of the number of replacements your algorithm is doing, as I need to keep track of it?
- using the whole header range is very interesting, but replacing it actually overwrites the whole header, including any text box. That doesn't work in my case as I need to preserve everything but the strings I am looking for.
- though your "if" line can go fast indeed, I do have a concern with processing speed, since the documents that are used with the macro can have any number of pages/sections (from 1 to 1000's of pages), in which case I want to avoid searching those sections that are linked, since the strings have already been searched for in the parent sections. Consider the fact that if a 500 pages document has 100 different sections (i.e. say 100 different headers and 400 "linked headers"), going through each header would be time-consuming, while skipping those linked headers would help processing the algorithm faster. I assume that using the line "for each oHF in oSection.Headers" goes indeed into each header, whatever it is, and whatever its state is. So it is really great, but not perfect in my case, since it may fall in a time-consuming approach, which I want to avoid...
I hope my explanation is now clear enough. But even if that doesn't solve my issue yet, you did give me a few interesting ideas that I may use elsewhere in my macro! :-)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules