R
Rickeh
Hi im wrting a program in C#.NET and I'm using Word Automation to
manipulate a Word document and its paragraphs. Basically this is what I
have so far:
<existing code to open a word doc>
<button click>
Word.Document oWordDoc = oWordApp.ActiveDocument;
Word.Paragraphs oWordDocp = oWordDoc.Paragraphs;
For (int i = 1; i <= oWordDocp.Count; i++)
{
label1.Text = oWordDocp.Range.Text;
}
The code counts the number of paragraphs and only prints the last
paragraph within the document. What it's meant to do is step through
the paragraphs (the For statement).
I will work on it a little later to try to increment each paragraph 1
by 1 and display the text in each paragraph within the C# program. Also
I have noticed that every white space in-between paragraphs is also
counted as a paragraph, any way around this? My overall aim is to count
the number of words within a paragraph and if they meet the requirement
output/copy the text if not move onto the next paragraph (while
excluding white spaces). I'm guessing I will be using a For Loop
similar to the one above or maybe a Do While. I know that this program
is in C#.NET but im happy for help in VBA. (cross language programming
through .NET shouldnt be a problem)
Any ideas?
manipulate a Word document and its paragraphs. Basically this is what I
have so far:
<existing code to open a word doc>
<button click>
Word.Document oWordDoc = oWordApp.ActiveDocument;
Word.Paragraphs oWordDocp = oWordDoc.Paragraphs;
For (int i = 1; i <= oWordDocp.Count; i++)
{
label1.Text = oWordDocp.Range.Text;
}
The code counts the number of paragraphs and only prints the last
paragraph within the document. What it's meant to do is step through
the paragraphs (the For statement).
I will work on it a little later to try to increment each paragraph 1
by 1 and display the text in each paragraph within the C# program. Also
I have noticed that every white space in-between paragraphs is also
counted as a paragraph, any way around this? My overall aim is to count
the number of words within a paragraph and if they meet the requirement
output/copy the text if not move onto the next paragraph (while
excluding white spaces). I'm guessing I will be using a For Loop
similar to the one above or maybe a Do While. I know that this program
is in C#.NET but im happy for help in VBA. (cross language programming
through .NET shouldnt be a problem)
Any ideas?