By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Creating microsoft word document using C#.net

P: n/a
I'm using the following code to create word document but the problem is if
you go to task manager you'll see a WINWORD.EXE process is running but not
the application, here is the code:
Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
docType, ref isVisible);
WordApp.Visible = true;
aDoc.Activate();
WordApp.Selection.TypeText("Hello");
WordApp.Selection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;

any suggestions

thanks
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Do you want to see the application, or not see the process running at all?

I’m guessing it is the latter, and if that is the case... then the answer is
no.

Word is required for the construction of the document with the code you laid
out, just think, without running word, the interop libraries would need to
know how to act like word, awful needless really, so instead, the interop
provides a way for you to talk to Word and have it do your bidding.

If you are hell bent against having Word run at all... one option is always
to build the Word doc from scratch according to the documentation available
on it.

Brendan
"Zeke" wrote:
I'm using the following code to create word document but the problem is if
you go to task manager you'll see a WINWORD.EXE process is running but not
the application, here is the code:
Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
docType, ref isVisible);
WordApp.Visible = true;
aDoc.Activate();
WordApp.Selection.TypeText("Hello");
WordApp.Selection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;

any suggestions

thanks

Nov 17 '05 #2

P: n/a
Hello Brendan
All what i'm trying to do is launching micosoft word so i can write to it
through the web application but the problem is the code that i wrote just
Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
application
thanks

"Brendan Grant" wrote:
Do you want to see the application, or not see the process running at all?

I’m guessing it is the latter, and if that is the case... then the answer is
no.

Word is required for the construction of the document with the code you laid
out, just think, without running word, the interop libraries would need to
know how to act like word, awful needless really, so instead, the interop
provides a way for you to talk to Word and have it do your bidding.

If you are hell bent against having Word run at all... one option is always
to build the Word doc from scratch according to the documentation available
on it.

Brendan
"Zeke" wrote:
I'm using the following code to create word document but the problem is if
you go to task manager you'll see a WINWORD.EXE process is running but not
the application, here is the code:
Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
docType, ref isVisible);
WordApp.Visible = true;
aDoc.Activate();
WordApp.Selection.TypeText("Hello");
WordApp.Selection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;

any suggestions

thanks

Nov 17 '05 #3

P: n/a
So you want the web application to launch Word so that it is visible to the
user?

Brendan
"Zeke" wrote:
Hello Brendan
All what i'm trying to do is launching micosoft word so i can write to it
through the web application but the problem is the code that i wrote just
Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
application
thanks

"Brendan Grant" wrote:
Do you want to see the application, or not see the process running at all?

I’m guessing it is the latter, and if that is the case... then the answer is
no.

Word is required for the construction of the document with the code you laid
out, just think, without running word, the interop libraries would need to
know how to act like word, awful needless really, so instead, the interop
provides a way for you to talk to Word and have it do your bidding.

If you are hell bent against having Word run at all... one option is always
to build the Word doc from scratch according to the documentation available
on it.

Brendan
"Zeke" wrote:
I'm using the following code to create word document but the problem is if
you go to task manager you'll see a WINWORD.EXE process is running but not
the application, here is the code:
Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
docType, ref isVisible);
WordApp.Visible = true;
aDoc.Activate();
WordApp.Selection.TypeText("Hello");
WordApp.Selection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;

any suggestions

thanks

Nov 17 '05 #4

P: n/a
exacltly,i've done before as windows application but its not working as web
application.
thanks

"Brendan Grant" wrote:
So you want the web application to launch Word so that it is visible to the
user?

Brendan
"Zeke" wrote:
Hello Brendan
All what i'm trying to do is launching micosoft word so i can write to it
through the web application but the problem is the code that i wrote just
Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
application
thanks

"Brendan Grant" wrote:
Do you want to see the application, or not see the process running at all?

I’m guessing it is the latter, and if that is the case... then the answer is
no.

Word is required for the construction of the document with the code you laid
out, just think, without running word, the interop libraries would need to
know how to act like word, awful needless really, so instead, the interop
provides a way for you to talk to Word and have it do your bidding.

If you are hell bent against having Word run at all... one option is always
to build the Word doc from scratch according to the documentation available
on it.

Brendan
"Zeke" wrote:

> I'm using the following code to create word document but the problem is if
> you go to task manager you'll see a WINWORD.EXE process is running but not
> the application, here is the code:
>
>
> Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
> docType, ref isVisible);
> WordApp.Visible = true;
> aDoc.Activate();
> WordApp.Selection.TypeText("Hello");
> WordApp.Selection.ParagraphFormat.Alignment =
> Word.WdParagraphAlignment.wdAlignParagraphCenter;
> WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
>
> any suggestions
>
> thanks

Nov 17 '05 #5

P: n/a
Ahh, that makes sense... and is unfortunately not possible, at least not as
you describe it.

The ASP.NET application you are hosting is being served up by a server,
while the client viewing it may have word installed, has it well outside of
the reach of the server. This is of course by design, after all, would you
like any old web page to be able to easily launch applications on your
desktop just because you browsed there?

If you are hell bent on having a web page launch word on the client PC...
one way to do that would be to create a Windows Form control whose sole job
is doing the work with Word that you want. This control would be hosted
within the web page that is served to the client, upon receiving, the client
would download and run the control.

This method is not perfect though, as it would make several key assumptions,
any of which not being true would cause this method to fail.

The two big things you need to make sure of (other than the obvious of
having Word installed), is that the client has the .NET Framework installed,
and that they and the control have sufficient permissions on the PC to
interop with Word and do what you want with it.

Brendan
"Zeke" wrote:
exacltly,i've done before as windows application but its not working as web
application.
thanks

"Brendan Grant" wrote:
So you want the web application to launch Word so that it is visible to the
user?

Brendan
"Zeke" wrote:
Hello Brendan
All what i'm trying to do is launching micosoft word so i can write to it
through the web application but the problem is the code that i wrote just
Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
application
thanks

"Brendan Grant" wrote:

> Do you want to see the application, or not see the process running at all?
>
> I’m guessing it is the latter, and if that is the case... then the answer is
> no.
>
> Word is required for the construction of the document with the code you laid
> out, just think, without running word, the interop libraries would need to
> know how to act like word, awful needless really, so instead, the interop
> provides a way for you to talk to Word and have it do your bidding.
>
> If you are hell bent against having Word run at all... one option is always
> to build the Word doc from scratch according to the documentation available
> on it.
>
> Brendan
>
>
> "Zeke" wrote:
>
> > I'm using the following code to create word document but the problem is if
> > you go to task manager you'll see a WINWORD.EXE process is running but not
> > the application, here is the code:
> >
> >
> > Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
> > docType, ref isVisible);
> > WordApp.Visible = true;
> > aDoc.Activate();
> > WordApp.Selection.TypeText("Hello");
> > WordApp.Selection.ParagraphFormat.Alignment =
> > Word.WdParagraphAlignment.wdAlignParagraphCenter;
> > WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
> >
> > any suggestions
> >
> > thanks

Nov 17 '05 #6

P: n/a
I totally apreciate your help,would you be able to show me an example how you
call a windows form from web application?
thank you.

"Brendan Grant" wrote:
Ahh, that makes sense... and is unfortunately not possible, at least not as
you describe it.

The ASP.NET application you are hosting is being served up by a server,
while the client viewing it may have word installed, has it well outside of
the reach of the server. This is of course by design, after all, would you
like any old web page to be able to easily launch applications on your
desktop just because you browsed there?

If you are hell bent on having a web page launch word on the client PC...
one way to do that would be to create a Windows Form control whose sole job
is doing the work with Word that you want. This control would be hosted
within the web page that is served to the client, upon receiving, the client
would download and run the control.

This method is not perfect though, as it would make several key assumptions,
any of which not being true would cause this method to fail.

The two big things you need to make sure of (other than the obvious of
having Word installed), is that the client has the .NET Framework installed,
and that they and the control have sufficient permissions on the PC to
interop with Word and do what you want with it.

Brendan
"Zeke" wrote:
exacltly,i've done before as windows application but its not working as web
application.
thanks

"Brendan Grant" wrote:
So you want the web application to launch Word so that it is visible to the
user?

Brendan
"Zeke" wrote:

> Hello Brendan
> All what i'm trying to do is launching micosoft word so i can write to it
> through the web application but the problem is the code that i wrote just
> Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
> application
> thanks
>
> "Brendan Grant" wrote:
>
> > Do you want to see the application, or not see the process running at all?
> >
> > I’m guessing it is the latter, and if that is the case... then the answer is
> > no.
> >
> > Word is required for the construction of the document with the code you laid
> > out, just think, without running word, the interop libraries would need to
> > know how to act like word, awful needless really, so instead, the interop
> > provides a way for you to talk to Word and have it do your bidding.
> >
> > If you are hell bent against having Word run at all... one option is always
> > to build the Word doc from scratch according to the documentation available
> > on it.
> >
> > Brendan
> >
> >
> > "Zeke" wrote:
> >
> > > I'm using the following code to create word document but the problem is if
> > > you go to task manager you'll see a WINWORD.EXE process is running but not
> > > the application, here is the code:
> > >
> > >
> > > Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
> > > docType, ref isVisible);
> > > WordApp.Visible = true;
> > > aDoc.Activate();
> > > WordApp.Selection.TypeText("Hello");
> > > WordApp.Selection.ParagraphFormat.Alignment =
> > > Word.WdParagraphAlignment.wdAlignParagraphCenter;
> > > WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
> > >
> > > any suggestions
> > >
> > > thanks

Nov 17 '05 #7

P: n/a
A windows form from a web application? Unless you are using something like
remoting or some other communications mechanism and the windows application
is already running... you are not going to be able to call a windows form
from a web application as you would be running into the same issue as trying
to launch Word on the client PC from the server.

Brendan

"Zeke" wrote:
I totally apreciate your help,would you be able to show me an example how you
call a windows form from web application?
thank you.

"Brendan Grant" wrote:
Ahh, that makes sense... and is unfortunately not possible, at least not as
you describe it.

The ASP.NET application you are hosting is being served up by a server,
while the client viewing it may have word installed, has it well outside of
the reach of the server. This is of course by design, after all, would you
like any old web page to be able to easily launch applications on your
desktop just because you browsed there?

If you are hell bent on having a web page launch word on the client PC...
one way to do that would be to create a Windows Form control whose sole job
is doing the work with Word that you want. This control would be hosted
within the web page that is served to the client, upon receiving, the client
would download and run the control.

This method is not perfect though, as it would make several key assumptions,
any of which not being true would cause this method to fail.

The two big things you need to make sure of (other than the obvious of
having Word installed), is that the client has the .NET Framework installed,
and that they and the control have sufficient permissions on the PC to
interop with Word and do what you want with it.

Brendan
"Zeke" wrote:
exacltly,i've done before as windows application but its not working as web
application.
thanks

"Brendan Grant" wrote:

> So you want the web application to launch Word so that it is visible to the
> user?
>
> Brendan
>
>
> "Zeke" wrote:
>
> > Hello Brendan
> > All what i'm trying to do is launching micosoft word so i can write to it
> > through the web application but the problem is the code that i wrote just
> > Initiate the process "WINWORD.EXE" but it won't launch the microsoft word
> > application
> > thanks
> >
> > "Brendan Grant" wrote:
> >
> > > Do you want to see the application, or not see the process running at all?
> > >
> > > I’m guessing it is the latter, and if that is the case... then the answer is
> > > no.
> > >
> > > Word is required for the construction of the document with the code you laid
> > > out, just think, without running word, the interop libraries would need to
> > > know how to act like word, awful needless really, so instead, the interop
> > > provides a way for you to talk to Word and have it do your bidding.
> > >
> > > If you are hell bent against having Word run at all... one option is always
> > > to build the Word doc from scratch according to the documentation available
> > > on it.
> > >
> > > Brendan
> > >
> > >
> > > "Zeke" wrote:
> > >
> > > > I'm using the following code to create word document but the problem is if
> > > > you go to task manager you'll see a WINWORD.EXE process is running but not
> > > > the application, here is the code:
> > > >
> > > >
> > > > Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref
> > > > docType, ref isVisible);
> > > > WordApp.Visible = true;
> > > > aDoc.Activate();
> > > > WordApp.Selection.TypeText("Hello");
> > > > WordApp.Selection.ParagraphFormat.Alignment =
> > > > Word.WdParagraphAlignment.wdAlignParagraphCenter;
> > > > WordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
> > > >
> > > > any suggestions
> > > >
> > > > thanks

Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.