Monday, June 21, 2010

How to open and Edit MSoffice document from C#.Net

Lots of people asking me how to open and edit MSoffice document from C#.Net.
Here i am giving you the way.

May you know all these and if have any better solution then comment me.

1. For just launching word. ( No need to specify the path of word exe)

2. For launching word with specifying file name.
Process.Start("Winword.exe", "My.doc");

If you want to create, edit any document file from C# Then follow these steps.

1.  From Add reference add a COM reference.
2.  Select "Microsoft Word 11.0 Object Library" Type lib version 8.3.
     ( It will vary upon library installed on your system)
     If you want to open and Edit Access, Excel files then add their respective libraries.
3. Now use the classes given by API for operating with files.

Here is a sample for word file..

using Microsoft.Office.Interop.Word;
ApplicationClass WordApp = new ApplicationClass();
   object _fileName = "My.Doc";
   object _readOnly = false;
   object _isVisible = true;
   object missing = System.Reflection.Missing.Value;
   WordApp.Visible = true;

   //the number of parameter on open method will vary according to referenced object library version
   Document aDoc = WordApp.Documents.Open(ref _fileName, ref missing, ref _readOnly, ref missing, ref missing, ref missing, ref missing, ref                                   missing, ref missing, ref missing, ref missing, ref _isVisible, ref missing, ref missing, ref missing, ref missing);

Wednesday, June 9, 2010

Free Online Exam / Certification

Hello Friends,
After a long time i am again here with some new topic.
Today i am giving you some Free Online Exam link which are very helpful for certification and you knowledge.

Even i am also doing the same way to update myself.

If you have anymore link just comment me i will post over here.

1. RankSheet:-  for .Net, java, Sql and all
2. TestWorld:- for Microsoft, Cisco, Sun and all
3. JavaBlackBelt:- for java and some editors