How to Programatically paste the clipboard contents to a word docu

T

ton_cul

Can anyone tell me how to Programatically paste the clipboard contents to a
word document using C#??

I am very new to programming (2 months). I am using Visual Studio.NET and
C#. I have made an Add-In for Word. One of the controls in my Add-In
Programatically copies a textbox (richTextBox1) contents to the Clipboard. I
used the following code:

Clipboard.SetText(richTextBox1.Text);

Then if I right click and select Paste the contents are pasted onto the Word
document.

However, I would like to Programatically paste the clipboard contents to
the word document? Can anyone tell me how to Programatically paste the
clipboard contents to a word document using C#??

I WAS able to instantiate a class using the "Interface" in the Object
Browser at Microsoft.Office.Interop.Word named "Selection" which contains a
method named "void Paste()".

However when I derived a class from it and then instantiated the class and
called the "Paste()" method it threw an error because there is no code in the
paste method. Can you give me an example of code that I can put into the past
method??

namespace WordAddIn2
{
class Class2:Selection //Implements the Interface found at
Microsoft.Office.Interop.Word.Selection
{
#region Selection Members...


public void Paste() // The paste method of the derived class
named Class2
{

throw new NotImplementedException();
}
................................................................................................................................................................................................................


Class2 y = new Class2(); // In my Windows Form I have
instantiated Class2 so that I can use the Paste method
y.Paste();

..................................................................................................................................................................................................................

When I run the program it throws an exception because I have not Implemented
the Paste Method. The problem is that I do not know how to Implement the
Paste method. Does anyone know how?????
 
C

Cindy M.

Duplicate question answered in the
office.developer.automation group

Cindy Meister
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top