Asked by:
How can I programmatically walk through all of the elements of a word document (in order)?

Question
-
I'm trying to write a simple program that converts a Word document to a custom format, and shows indentation. The closest thing that meets my needs is converting the document to HTML format but I don't have code for that.
I care about: Headings, Tables, Images, and Paragraphs.
So I want to start at the front of the document and each of these items "IN ORDER".
So far I see there are collections of objects, Tables, Image, Paragraphs but I don't (yet) know how to order these things. For example, heading, paragraph, table, heading, heading, paragraph, image, table, paragraph.
So if I have something like this (I'm including the styles in {stylename})
========================================
{Heading 1}Introduction
This is a nice document.
{Heading 2}Audience
This has a nice audience.
{Heading 1}System Summary
{Normal} Some stuff.
{Normal} Some stuff2.
{Heading 2}Important Topics
TABLE GOES HERE (has several paragraphs)
{Heading 1}Detailed Notes
{Normal}more stuff
========================================
I want to produce something like this:
* Introduction
This is a nice document.
** Audience
This has a nice audience.
* System Summary
Some stuff.
Some stuff2.
** Important Topics
Messed up table goes here... :-)
* Detailed Notes
more stuff
I'm currently looping over all of the paragraphs in the document and when I get the style that begins with "Heading ", I know to print a heading indicator.
The problem is I don't (yet) know how to handle tables, or pictures.
I don't need to embed pictures I can just say [pict would go here], but
I would like to know how to identify the tables.
I know there are utilities to convert word to other formats but I'm interested in learning how word works as much as doing this conversion.- Moved by Liliane Teng Wednesday, June 1, 2011 2:14 AM (From:Visual Basic General)
Wednesday, May 25, 2011 8:22 PM
All replies
-
Hi,
Please delete this duplicate thread:>>
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/21b3bf24-282f-495b-8926-f9774cdae6c8
Please also delete this duplicate thread:>>
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/9912c2c5-d0de-473f-9911-806b15f00c94
There will be a DELETE link on the top or bottom edge of those posts when you view them.
We know you can be desperate for an answer, but there is no need to post the same or a similar post more than once.
Your question(s) now and in the future will still get noticed. :-) :-D
Thank you for your understanding.
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
Wednesday, May 25, 2011 9:48 PM -
Hello T0mic,
Thanks for your post.
Based on your description, I recommend you could repost on Word for Developers forum for more better suggestions because more this aspect experts live there. Thanks for your understanding.
Best regards
Liliane Teng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, May 30, 2011 7:35 AM -
Hi T0mic,
I moved this thread to Off-Topic forum. Please repost on appropriate forum for more suggestions. If you have any concerns, please feel free to follow up.
Have a nice day.
Best regards
Liliane Teng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Wednesday, June 1, 2011 2:18 AM -
I didn't know I had posted it twice. I tried to click on the links and they didn't work. It's not a big deal, but I wanted to see what I did wrong so I don't do it again. Sorry about that. Also, you mentioned this is a duplicate... Did you find this question already asked and answered? If so, can you tell me what string you searched on so I can find it. Thanks.Monday, June 6, 2011 4:10 PM
-
Hi T0mic,
You posted three duplicate posts. On this forum, our policy is one thread for one question. You will get better support for this one question because more community members will focus on it. So please try not to post same threads many times. If we found, we will merge or delete them. We have deleted your other two posts. Thanks for your understanding.
If you have any concerns, please feel free to follow up.
Have a nice day.
Best regards
Liliane Teng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tuesday, June 7, 2011 3:13 AM