tags:

views:

24

answers:

1

Could you please explain what is the difference between doc.Content.Text and doc.Range(start, end).Text

Actually, if I extract a string like

doc.Content.Text.SubString(start, lenofText)

and if I do the same with

doc.Range(start, start + lenofText)

I get correct result for doc.Content.Text but incorrect result with doc.Range ... do you know the reason? I need to find a text and then convert it to a Hyper LINK but the doc.Range does not give the me the correct results...

+1  A: 

Your description is a little vague (for instance, how is it not the correct results?) but a document is actually comprised of as many as 17 story parts (which includes things like the main story [the document area], footers, headers, footnotes, and comments). 'Content' refers specifically to the main text story. ‘Doc.Range’ is broader and can include more than one story. If the results are not correct because it looks like the text is offset by a certain number of characters, it may be counting other stories. If you want to limit the results to the body text, specify one of the following:

doc.Content
doc.StoryRanges(wdMainTextStory)
ForEachLoop