Discussion:
Get a style marked word/s from a paragraph
(too old to reply)
inpuarg
2006-04-29 16:37:21 UTC
Permalink
I have some paragraphs in a word document. Looks like :

P1 :
XXX YYY rest of the text

P2 :
XXX rest of the text

P3 :
XXX YYY ZZZ rest of the text

P4 :
XXX rest of the text


XXX , YYY , ZZZ are marked with WORDNNN style. rest of the text are normal
style. there are no any delimiter between them.

So - i know the style's name. Can i parse , marked as WORDNNN style text ? and
get XXX ? Is it possible ?
Jezebel
2006-04-29 16:40:52 UTC
Permalink
Find will retrieve text based on style.
Post by inpuarg
XXX YYY rest of the text
XXX rest of the text
XXX YYY ZZZ rest of the text
XXX rest of the text
XXX , YYY , ZZZ are marked with WORDNNN style. rest of the text are normal
style. there are no any delimiter between them.
So - i know the style's name. Can i parse , marked as WORDNNN style text ? and
get XXX ? Is it possible ?
inpuarg
2006-04-29 17:00:16 UTC
Permalink
could you please give me more detail ?
That FIND method - is the method of which class ?

Document.Find or Application.Find or Content.find or Style.Find or ?

(by the way - i am using c# 2005 )
Post by Jezebel
Find will retrieve text based on style.
inpuarg
2006-04-29 17:12:23 UTC
Permalink
I have only this :(



Microsoft.Office.Interop.Word.Range c = this.Paragraphs[1].Range;


msdn sucks. no sample . no detail. nothing.
Post by inpuarg
could you please give me more detail ?
That FIND method - is the method of which class ?
Document.Find or Application.Find or Content.find or Style.Find or ?
(by the way - i am using c# 2005 )
Post by Jezebel
Find will retrieve text based on style.
Charles Kenyon
2006-04-29 17:58:32 UTC
Permalink
You need to learn how Word works before you start trying to program it.
Sorry. That is just how it is.

Try within Word recording a macro that searches for your style and examine
the code.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by inpuarg
could you please give me more detail ?
That FIND method - is the method of which class ?
Document.Find or Application.Find or Content.find or Style.Find or ?
(by the way - i am using c# 2005 )
Post by Jezebel
Find will retrieve text based on style.
Jezebel
2006-04-30 02:04:09 UTC
Permalink
If you can't use Help to understand the Find object, your project is doomed
from the start.
Post by inpuarg
could you please give me more detail ?
That FIND method - is the method of which class ?
Document.Find or Application.Find or Content.find or Style.Find or ?
(by the way - i am using c# 2005 )
Post by Jezebel
Find will retrieve text based on style.
inpuarg
2006-05-01 08:48:27 UTC
Permalink
I've found the solution but not so easy.
Before chm help , or earlier version of MSDN Library , Microsoft was working
for supplying a good help document. At least for main methods , like Find method
, there was a sample.
I am using c# 2005 , VSTO2005 and related MSDN Library. There is no any sensible
explanation or sample.

public partial class ThisDocument
{
Microsoft.Office.Interop.Word.Selection activeSelection = null;
Microsoft.Office.Interop.Word.Range range = null;
private void ThisDocument_Startup(object sender, System.EventArgs e)
{
this.SelectionChange += new
Microsoft.Office.Tools.Word.SelectionEventHandler(ThisDocument_SelectionChange);

for (int i = 1; i < this.Paragraphs.Count+1; i++)
{
range = this.Paragraphs[i].Range;
range.Select();
string word = "";
string response = "";
bool ret = parseWordAndResponse(ref word, ref response);
ret = insertWordToDatabase(word, response);
}



private void ThisDocument_SelectionChange(object sender,
Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
activeSelection = e.Selection;
}



C#
public interface Find

Word Primary Interop Assembly Reference
Find.Execute Method

Runs the specified find operation.
Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in microsoft.office.interop.word.dll)


bool Execute(
[In, Optional] ref object FindText,
[In, Optional] ref object MatchCase,
[In, Optional] ref object MatchWholeWord,
[In, Optional] ref object MatchWildcards,
[In, Optional] ref object MatchSoundsLike,
[In, Optional] ref object MatchAllWordForms,
[In, Optional] ref object Forward,
[In, Optional] ref object Wrap,
[In, Optional] ref object Format,
[In, Optional] ref object ReplaceWith,
[In, Optional] ref object Replace,
[In, Optional] ref object MatchKashida,
[In, Optional] ref object MatchDiacritics,
[In, Optional] ref object MatchAlefHamza,
[In, Optional] ref object MatchControl
);
Charles Kenyon
2006-05-01 15:15:08 UTC
Permalink
Again, this newsgroup is about vba, not vb, not C.
vba's help has nice information on Find, including examples. However, it is
on the Find object, rather than a Find method.

Before trying to program Word, learn Word.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by inpuarg
I've found the solution but not so easy.
Before chm help , or earlier version of MSDN Library , Microsoft was working
for supplying a good help document. At least for main methods , like Find method
, there was a sample.
I am using c# 2005 , VSTO2005 and related MSDN Library. There is no any sensible
explanation or sample.
public partial class ThisDocument
{
Microsoft.Office.Interop.Word.Selection activeSelection = null;
Microsoft.Office.Interop.Word.Range range = null;
private void ThisDocument_Startup(object sender, System.EventArgs e)
{
this.SelectionChange += new
Microsoft.Office.Tools.Word.SelectionEventHandler(ThisDocument_SelectionChange);
for (int i = 1; i < this.Paragraphs.Count+1; i++)
{
range = this.Paragraphs[i].Range;
range.Select();
string word = "";
string response = "";
bool ret = parseWordAndResponse(ref word, ref response);
ret = insertWordToDatabase(word, response);
}
private void ThisDocument_SelectionChange(object sender,
Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
activeSelection = e.Selection;
}
C#
public interface Find
Word Primary Interop Assembly Reference
Find.Execute Method
Runs the specified find operation.
Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in
microsoft.office.interop.word.dll)
bool Execute(
[In, Optional] ref object FindText,
[In, Optional] ref object MatchCase,
[In, Optional] ref object MatchWholeWord,
[In, Optional] ref object MatchWildcards,
[In, Optional] ref object MatchSoundsLike,
[In, Optional] ref object MatchAllWordForms,
[In, Optional] ref object Forward,
[In, Optional] ref object Wrap,
[In, Optional] ref object Format,
[In, Optional] ref object ReplaceWith,
[In, Optional] ref object Replace,
[In, Optional] ref object MatchKashida,
[In, Optional] ref object MatchDiacritics,
[In, Optional] ref object MatchAlefHamza,
[In, Optional] ref object MatchControl
);
inpuarg
2006-05-10 12:41:26 UTC
Permalink
i know word. i don 't have to learn vba. i am programming c#.
if vba has a good documentation this is good for you.
i am simply demanging the same :)

my only mistake was sending this issue to this group . that 's all .

i even don 't have to know word. if you want developers to improve your product
with some add-ins , macros , you have to provide a good documentation. and in
msdn .net help theese are not provided. that was all that i 'm critizing.


On Mon, 1 May 2006 10:15:08 -0500, "Charles Kenyon"
Post by Charles Kenyon
Again, this newsgroup is about vba, not vb, not C.
vba's help has nice information on Find, including examples. However, it is
on the Find object, rather than a Find method.
Before trying to program Word, learn Word.
Loading...