Step 1
1.
Add Class
Library name "WordConnector"
Step 2
Rename Class1.cs
as "clsConnector.cs"
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace WordConnector
{
public class clsConnector
{
public void Start(Word.Document objDocument)
{
new
frmWord(objDocument).Show();
}
}
}
----------------------------------------
Add form rename as "frmWord.cs"
-------------------------------------------------
using System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
WordConnector
{
public partial class frmWord : Form
{
string
sDocumentName = string.Empty;
public
frmWord()
{
InitializeComponent();
}
public
frmWord(Word.Document objDocument)
{
InitializeComponent();
this.sDocumentName
= objDocument.Name.ToString();
this.Text
= sDocumentName.Replace(".doc", string.Empty).ToUpper();
}
}
}
Step 3
Step 4
Click on Assembly
Information button
Step 5
Check Make assembly COM-Visible
Step 6
Click Build and
Scroll down check Register for COM interop.
Step 7
Click Signing menu
Step 8
1. Check sign the assembly.
2. Click choose a strong name key file combo box <New>
Step 9
Give key file name as "Key_WordConnector"
Step 10
Copy
WordConnector.dll and WordConnector.tlb from project bin
folder
Step 11
Pate WordConnector.dll and WordConnector.tlb in " C:\WINDOWS\system32"
Step 12
1. Open winword document and Press Alt+F11
2. Write macro in module.
3.Click Tools -> References - >
5. Browse for WordConnector.tlb
Check Wordconnector
Add this macro in module
Press F8 and see form will open from worddocument
No comments:
Post a Comment