Using Rowcount and Top keyword for controlling number of records returned

Hi,

Many a times in a query we need to limit down the number of records returned in the query. This can be done in two ways using the TOP keyword or the row count keyword.

Select top 10 from Table

This will return the top 10 records from the query. We can also make this dynamic by making the Value in Top keyword to come from a variable.

DECLARE @top INT
SET @top = 10
SELECT TOP(@top) * FROM Table

Continued...

Programmatically Embedding another file to the word document

Hi

Many a times we want to embed some document in the word file, with the help of Insert-> File-> Select File menu item. This will copy the content of the file to the word document. This can also be done programmatically. 

String LocationOfFileToMerge = "C:\\Myfile.doc";

range.InsertFile(LocationOfFileToMerge,ref oMissing, ref oFalse, ref oFalse, ref oFalse);

We can also embed the document in the word file instead of copying the text of the document. In this case you can embed any kind of document.


Object NameForLabel = "File Name";

Continued...

Word Automation and Basic text formatting option

Hi,

when you start working with word programmatically, many a times you will have to add some text in the word document with formatting. Word automation gives you easy way top format the text that you are writing in the Word document programmatically.

To make the same impact as would an enter button in the word document we can use the following code.

oWord.Selection.TypeParagraph();

Basically this will enter a new paragraph in the word document. But you are in a bullet mode than this will take you to next line and also add the next bullet in the sequence.

Some of the common word formatting functionality can easily be performed with the help of word automation.

Continued...

Word automation and find and replace in Word document

Hi,

In My last two posts I talked about

ยท         How to open and close a word document programmatically.

Continued...

Saving word document in different format using Word Automation

Hi,

In my last post I talked about how to open and close a word document programmatically. In this post I will talk about how we can save the word document.

While using a word document there can be three kind of save functionality that can be required.

1.       When we open an existing word document and make some changes to the word document and save the word document.

Continued...

Microsoft word 2007 automation with C Sharp

Hi,

Some time in our project we need to work with word (winword) document programmatically. Word provides a good way to automate nearly all the functionality that can be used through interface.  The process of programmatically working with word document is commonly termed as word Automation.

I will be using a series of blogs to discuss some of the functionality that can be achieved through word automation. In this Blog I will discuss how we can start programmatically open a new or and existing word document and close it.

To work with word 2007 automation we need to have the word 2007 installed in the machine where the application will run. When we install the word 2007, it also installs with it the com component required to automate word 2007.

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia