How do I get the document part a Range is in?

J

Ji Zhou

Hello Dave,

We can first detect the range's story type,
http://msdn.microsoft.com/en-us/library/bb256041.aspx

If it is in the main document, range.StoryType returns wdMainTextStory
If it is in the header, range.StoryType returns wdPrimaryHeaderStory
If it is in the footer, range.StroyType returns wdPrimaryFooterStory

After that we can get the parent object respectively via,
Document.Content,
Document.Sections(1).Headers(wdHeaderFooterPrimary).Range
Document.Sections(1).Footers(wdHeaderFooterPrimary).Range

Is this what you looking for?

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

Worked great - thanks - dave


Hello Dave,

We can first detect the range's story type,
http://msdn.microsoft.com/en-us/library/bb256041.aspx

If it is in the main document, range.StoryType returns wdMainTextStory
If it is in the header, range.StoryType returns wdPrimaryHeaderStory
If it is in the footer, range.StroyType returns wdPrimaryFooterStory

After that we can get the parent object respectively via,
Document.Content,
Document.Sections(1).Headers(wdHeaderFooterPrimary).Range
Document.Sections(1).Footers(wdHeaderFooterPrimary).Range

Is this what you looking for?

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top