Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Copy-paste office documents via clipboard

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
braz - 22 Mar 2007 17:24 GMT
        Copy-paste office documents via clipboard
        

       
Hello!

 I need to copy paste office documents via clipboard. I wrote next code:



public void InsertDocument(object mDocument, string documentFileName)

{

if(mDocument!=null)

{

FileStream fileStream = new FileStream(documentFileName,FileMode.Open);

byte[] file = new byte[(int)fileStream.Length];

fileStream.Read(file,0,(int)fileStream.Length);

fileStream.Close();

Clipboard.SetDataObject(new
DataObject(System.Windows.Forms.DataFormats.FileDrop,file), false);

object selection = mDocument.GetType().InvokeMember("Selection",
BindingFlags.GetProperty, null, mMSWord, null);

selection.GetType().InvokeMember("Paste",BindingFlags.InvokeMethod, null,
selection, null);

}

}





The last command couses inner exception "command error". Is there wrong
DataFormat ? What should I put to the clipboard, file in binary or file path
as a string ? What should I correct to get it working ?



Thanks
JensB - 30 Mar 2007 16:47 GMT
Hi

I am not a C# programmer, but if you want to bring the content from a
word.doc file to another,
you could use this wordbasic command:
selection.InsertFile(documentFilename)

Might be at some help.

JensB

> Copy-paste office documents via clipboard
>
[quoted text clipped - 37 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.