Hi,
I am working on creating a .doc file by using .dot(Template) file using
Word.ApplicationClass. In this process I am having few tags in the template
file which I am trying to replace with some content. But when I am trying to
insert large text as the replacement text, I am getting an error "String too
long".

Following are the piece of code that I am using:

private void button1_Click(object sender, System.EventArgs e)
{
WordDoc wd = new WordDoc();
wd.Open("D:\\PTS\\Test1.dot");
object str = textBox1.Text; // It is a multiline text box where large text
is inserted
wd.FindAndReplacement("<<Body>>", str);
wd.SaveAs("D:\\PTS\\Test.doc");
wd.Quit();
}

public void FindAndReplacement(string strFind, object strReplace)
{
Word.ApplicationClass oWordAppl = new Word.ApplicationClass();
object missing = System.Reflection.Missing.Value;
object story = Word.WdUnits.wdStory;
object ext = Word.WdMovementType.wdExtend;
object rp = Word.WdReplace.wdReplaceAll;
object strf = strFind;
object strr = strReplace;
oWordAppl.Selection.HomeKey(ref story,ref ext);
oWordAppl.Selection.Find.Execute(ref strf, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref strr, ref rp, ref missing,ref missing,ref missing, ref missing);
}

This code is however working for smaller texts. Please let me know if there
is anything wrong I m doing in this code. If the code is fine, then please
let me know how to fix the issue.

Note: I am using MS Word 2000 component in my C# aplication.

Thanx & regards,
Santhosh.B

Re: Facing problem using Word.Find.Execute method by Helmut

Helmut
Tue Aug 02 10:16:33 CDT 2005

Hi Santhosh,

the replacement string is limited to 255 characters.

Do You need help on a solution for longer strings,
or can You find out yourself, how to do it?

Maybe you even like to do it yourself. ;-)

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Facing problem using Word.Find.Execute method by Santhosh

Santhosh
Wed Aug 03 02:09:02 CDT 2005

Hi,
Thank you very much for the early reply.
My requirement is that I want to create a word document based on the inputs
given in a form. For ex: I have a form with the controls taking Header, Body
& footer details. I want to know which is the better way to create it. I have
couple of options in mind. Please let me know if any of the following
approach is fine or if there is any issues if I use any of these approach or
if there is any other way to achieve it.

1. I have text box controls that gets me Header, Body & Footer details and
then using these data, I go ahead and create a word document.
The issue with this approach is that I cannot use more than one formatting
techniques.
2. I use a .Net OCX component called DSO Framer with which I am free to
create any word document using all kinds of formatting.
The issue with this approach is that I am not able to disable just the
"save", "open", etc buttons individually.

Please let me know what I can do so that I can create the Body content using
DSO Framer kind of Active X controls and then add Header & Footer to that
content.

Thanks & Regards,
Santhosh.B


"Helmut Weber" wrote:

> Hi Santhosh,
>
> the replacement string is limited to 255 characters.
>
> Do You need help on a solution for longer strings,
> or can You find out yourself, how to do it?
>
> Maybe you even like to do it yourself. ;-)
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>

Re: Facing problem using Word.Find.Execute method by HelmutWeber

HelmutWeber
Wed Aug 03 03:58:03 CDT 2005

Hi Santosh,

> 1. I have text box controls that gets me Header, Body & Footer details and
> then using these data, I go ahead and create a word document.
> The issue with this approach is that I cannot use more than one formatting
> techniques.

Why? What is a formatting technique?

Once you have a word document, all kinds of formatting should be possible.

> 2. I use a .Net OCX component called DSO Framer

I'm not competent in this field, sorry.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000



Facing problem in reading ActiveDocument in Word by Santhosh

Santhosh
Thu Aug 04 04:45:44 CDT 2005

Hi,

I need to access the content of a given MS Word file.

For example the content is like this:
abcdefg
xyz
123

The file has 3 lines, and I need to get the 2nd line's value, in this case
"xyz".

Does anybody know how to do that? I have added the library and tried to do
it however it just can't seem to work. Really need an expert's help...

Thanks,
Santhosh

"Helmut Weber" wrote:

> Hi Santosh,
>
> > 1. I have text box controls that gets me Header, Body & Footer details and
> > then using these data, I go ahead and create a word document.
> > The issue with this approach is that I cannot use more than one formatting
> > techniques.
>
> Why? What is a formatting technique?
>
> Once you have a word document, all kinds of formatting should be possible.
>
> > 2. I use a .Net OCX component called DSO Framer
>
> I'm not competent in this field, sorry.
>
> Greetings from Bavaria, Germany
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
>
>

Re: Facing problem in reading ActiveDocument in Word by Doug

Doug
Thu Aug 04 07:13:01 CDT 2005

Assuming that the lines are separate pargraphs, use:

ActiveDocument.Paragraphs(2).Range


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Santhosh" <Santhosh@discussions.microsoft.com> wrote in message
news:95633471-700F-4A69-9582-C7E7CE01B17C@microsoft.com...
> Hi,
>
> I need to access the content of a given MS Word file.
>
> For example the content is like this:
> abcdefg
> xyz
> 123
>
> The file has 3 lines, and I need to get the 2nd line's value, in this case
> "xyz".
>
> Does anybody know how to do that? I have added the library and tried to do
> it however it just can't seem to work. Really need an expert's help...
>
> Thanks,
> Santhosh
>
> "Helmut Weber" wrote:
>
>> Hi Santosh,
>>
>> > 1. I have text box controls that gets me Header, Body & Footer details
>> > and
>> > then using these data, I go ahead and create a word document.
>> > The issue with this approach is that I cannot use more than one
>> > formatting
>> > techniques.
>>
>> Why? What is a formatting technique?
>>
>> Once you have a word document, all kinds of formatting should be
>> possible.
>>
>> > 2. I use a .Net OCX component called DSO Framer
>>
>> I'm not competent in this field, sorry.
>>
>> Greetings from Bavaria, Germany
>> Helmut Weber, MVP
>> "red.sys" & chr(64) & "t-online.de"
>> Word 2002, Windows 2000
>>
>>