473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Creating microsoft word document using C#.net

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
7 3866
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
2
by: QQ | last post by:
I wanted to know how to make a properly formated word document from asp. Can some one direct me to all the propertise of CreateObject("word.application"). Thanks!
2
by: Arvind P Rangan | last post by:
Hi all, trying to create word document using following syntax in c# private Word.ApplicationClass oWordApp = new Word.ApplicationClass(); Application throws error as : Exception Details:...
4
by: Nikhil Patel | last post by:
Hi all, I need to generate a word document and save it on the server from an ASP.Net application. Basically I want to load a word template and insert some field values from a dataset and save...
1
by: Novice | last post by:
Hi all, I'm using C# in my ASP.NET application and cannot seem to access the MS word libraries to create a word document for some reason. I have used both of these tutorials:...
3
by: Brian Cryer | last post by:
A project I'm about to start on has a requirement to create word documents on the fly for download from the website. To date all the code examples I've found on the net use automation (and by...
0
by: PracticalApps | last post by:
I looked to find a canned solution to create a Word document in my application and just couldn't find anything that just gets to the point. I would think, and I may be making too strong of an...
4
by: =?Utf-8?B?QXJ0?= | last post by:
Hello, I saw this posting and it is the closest place to ask this question. I am simply trying to create a Word document from a VB application I am wrting with Visual Studio 2005. I cut a...
2
by: uamusa | last post by:
I am Dynamically generating a proposal(report) in MS Word. By default the Paragraph Alignment is "Left". For the First 6 Paragraphs I set the Alignment to "Center", and then when attempting to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.