BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


.NET and XML
WS-Routing for .NET endpoints
Using XML and XSLT in VB.NET Jeopardy
Symmetric Encryption/Decryption with .NET
XInclude.NET 1.0
EXSLT.NET 1.0
How to read a XML file using XmlTextReader?
How to compare a XML element with XmlTextReader?
How to verify if an element is empty with XmlTextReader and IsEmptyElement?
How to check if the XML elements contains any attributes with XmlTextReader
How to avoid to read the XML declaration with XmlTextReader?
How to create a XML file with XmlTextWriter?
Is it possible to add attributes with XmlTextWriter?
How to Write a Comment to a XML File with XmlTextWriter and WriteComment?
How to add the XML Declaration with XmlTextWriter and WriteStartDocument?
How to use Indentation in XmlTextWriter?
What is the usage of WriteFullEndElement and how do I use?
How to include a CData block with XmlTextWriter and WriteCData?
How to write raw XML with XmlTextWriter?
How to add a namespace with the XmlTextWriter and WriteStartAttribute?
How to create a new xml file with XmlDocument?


 
 

<< XSLT 


By Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First Posted 10/22/2002
Times viewed 339

.Net, COM Interoperability and Word Object Model


This post contains attachments
v20021022220011.zip 

Summary This article explores the interaction of COM components like Microsoft Word application with .Net Framework.

 

In this article, I am going to explore how we can interact with COM components like Microsoft Word application. I will explain this concept with a program which was written in both VB.Net and C#.Net. This program basically counts the number of characters in your document and displays all those characters in your console window. This gives you an idea on how COM components can interact with .Net framework.

 

First you need to create the Interop Assembly using Type Library Importer (Tlbimp.exe), which is a tool that converts COM type library coclasses and interfaces into metadata.

To execute this article on your machine, Microsoft Word should be installed. If installed, find the path of MsWord9.olb file. In Ideal cases the path will be C:\Program Files\Microsoft Office\Office. Then create the interop assembly from the type library, using the following command.

 

C:\pandu\asp\Word>Tlbimp C:\Program Files\Microsoft Office\Office\ MsWord9.olb /silent /out:Word.dll

Here the second argument /silent suppress the display of successful messages.

 

This command instruction creates a metadata, which is the Interop assembly.

 

Create a word document by saving it as WordTest.doc in C: drive. You can save this file anywhere but you need to give the path of this file in your code.

Then write the following programs, which uses the created Interop Assembly:

  • wordConvert.cs

 Compile it as follows:

             C:\pandu\asp\Word>csc wordConvert.cs /r:Word.dll /r:System.dll

 Note that Word.dll and wordConvert.cs should be in the same folder.

  • wordConvert.vb

Compile it as follows:

            C:\pandu\asp\Word>vbc wordConvert.vb /r:Word.dll /r:System.dll

Note that Word.dll and wordConvert.cs should be in the same folder.

 Here you can notice the coding differences between the two languages and their syntax.

 

System Requirements:

.Net SDK

Additional information


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< XSLT 





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML