I am currently creating a macro that needs to save Word.Range instances to an array. I want those range objects to be anywhere in the document. For the regular content stuff this works just fine, but when I am trying to save a range in the header, I cannot get it to work.
The sub definition:
Function GetSelectionRanges(rRng As Object, sFind As String) As Variant
rRng is a StoryRange
The code for the regular conntent ranges is as follows:
Set tmpSelections(i) = WdDoc.Range(Start:=rRng.Start, End:=rRng.End)
This one works absolutely fine and I can work with it. I tried to extend it so it can store header objects as well:
Set tmpSelections(i) = WdDoc.StoryRanges(rRng.storytype).Range(Start:=rRng.Start, End:=rRng.End)
This, however, does not work. It says object does not support this attribute/method.
My problem at the moment is that the start and end are obtained correctly but if I use the WdDoc.Range method it uses the text stored in the regular content and thus not working as I want it to.
Definitions:
WdDoc As Object
tmpSelections() As Object
Later on I want to work with the single ranges and eventually replace values but that is a later step that cannot be incorporated in that routine.