Greg, I have a few questions:
1) Based on the loop you suggested, I see the line
if Shp.Type = msoTextBox Then
but I wonder if the following line would do the same, or means something else:
If Shp.TextFrame.HasText Then
If they don't do the same, I could use both within the same test...
2) Also, with using the line
For Each Shp In oHF.Range.ShapeRange
if one shape is not a text box, but contains other text boxes, would it required to add code to go into this shape and within each text box inside, or would the main loop do the job by itself?
I was using the following lines when I was working with Selections, and the code seemed to work:
If Shp.TextFrame.HasText Then
'blabla
Else
For j = 1 To Shp.CanvasItems.Count
If Shp.CanvasItems.Item(j).Type = msoTextBox Then
Should I use it again or not?
3) With the part that processes the headers in general, I noticed some weird behaviour using the code
For Each oSection In ActiveDocument.Sections
For Each oHF In oSection.Headers
With oHF
If .LinkToPrevious = False Or oSection.Index = 1 Then
''blablabla
Sometimes, one range is empty, so the code is going in the "blabla" section for nothing. So I thought I could test the range using
but even though the range is empty, this test would fail. I then noticed that the range actually has one space, so I changed the test to
same issue again. I then thought this would work:
If oHF.Range.Text <> "" And oHF.Range <> " " then
Naaaa... This one?
If len(oHF.Range) >1 then
but halas...
That's when I thought of using a string:
strHeaderText = oHF.Range
If Len(strHeaderText) > 1 Then
And this test works and gives me the expected result.
Now, why did the other tests fail, though their results were actually meeting the test conditions?