Creating a Word document from VB.NET 
Author Message
 Creating a Word document from VB.NET

Help,

I am trying to create a Word document from VB.NET and
having several problems. I am using the MS Word Object
Library 10 reference.

1. I have text that contains HTML formatting for bold,
underline, italics and indenting that I need to get into
the document. Is there a way to get this into a FormField
so that the text formatting is still there? I need this
to be done on the server side code because I can not
guarantee that each client will have Word 2000 on their
machine.

2. I have been able to instantiate an instance of the
Word.Application and Word.Document, as well as assigning
the proper template and using it to create the document
that I need. I am even able to save the document, but
when I try to access the document from word, or try to
delete it from the explorer I get an error that the
document is in use by another user.

I have tried using "Quit" from the application
and "Close" from the document and both of these give me a
message that they are "ambiguous across the inherited
interfaces ...". I have even tried
using "System.Runtime.InteropServices.Marshal.ReleaseComOb
ject(WordObj)" which I found on another article, but the
file still remains locked. I have to reboot my machine
before the file is released.

3. Is there a way to print a Word Document on the client
side if it is created on the server side? I can not find
anything that resembles a print feature from the object
model.

Any help would be greatly appreciated.



Sat, 29 Jan 2005 03:40:56 GMT  
 Creating a Word document from VB.NET
Hi,

For some more sample code about using Word object model in VB.NET, you can
check the following article:
HOW TO: Automate Word with VB .NET to Create a New Document  
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316383

However, even though you get through all the problems you listed, it is not
suitable to automate Office object model on the server-side, such as
ASP.NET. It may cause many problems because all current versions of
Microsoft Office were designed, tested, and configured to run as end-user
products on a client workstation. You can check the following article for
detailed information:
INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/support/kb/articles/q257/7/57.asp

Regards,
Elan Zhou
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net?  http://www.gotdotnet.com



Sun, 30 Jan 2005 09:30:52 GMT  
 Creating a Word document from VB.NET
You should use Word.ApplicationClass and Word.DocumentClass instead of
Word.Application and Word.Document.

Hope this helps.

Deepak.

Quote:

> Help,

> I am trying to create a Word document from VB.NET and
> having several problems. I am using the MS Word Object
> Library 10 reference.

> 1. I have text that contains HTML formatting for bold,
> underline, italics and indenting that I need to get into
> the document. Is there a way to get this into a FormField
> so that the text formatting is still there? I need this
> to be done on the server side code because I can not
> guarantee that each client will have Word 2000 on their
> machine.

> 2. I have been able to instantiate an instance of the
> Word.Application and Word.Document, as well as assigning
> the proper template and using it to create the document
> that I need. I am even able to save the document, but
> when I try to access the document from word, or try to
> delete it from the explorer I get an error that the
> document is in use by another user.

> I have tried using "Quit" from the application
> and "Close" from the document and both of these give me a
> message that they are "ambiguous across the inherited
> interfaces ...". I have even tried
> using "System.Runtime.InteropServices.Marshal.ReleaseComOb
> ject(WordObj)" which I found on another article, but the
> file still remains locked. I have to reboot my machine
> before the file is released.

> 3. Is there a way to print a Word Document on the client
> side if it is created on the server side? I can not find
> anything that resembles a print feature from the object
> model.

> Any help would be greatly appreciated.



Fri, 04 Feb 2005 23:06:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trouble Opening a Word Document with VB.NET,Open member not found in Documents

2. accessing word document through vb.net using word com object

3. opening and closing word document using vb,net

4. Closing Word Document/Application in VB.NET

5. Opening and Saving MS Word Documents using VB.NET

6. Using VB.Net to Generate MS Word Documents

7. How do I print a word document from VB.NET

8. Creating Word documents from an Embedded OLE Word Template

9. Creating table in Word document from VB Script

10. Creating Formatted Word documents from VB

11. Word Docs - Look for example to create them from VB.Net

12. VB.NEt Beginner: Creating a COM+ Object in VB.net

 

 
Powered by phpBB® Forum Software