Hi everybody,
Can you please tell me how to copy a metafile object in a clipboard and paste it in MS WORD 2007.
Code snippets will be more helpful.
Hi everybody,
Can you please tell me how to copy a metafile object in a clipboard and paste it in MS WORD 2007.
Code snippets will be more helpful.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nathan NZPosted Jul 21, 2008, 10:41 PM
Hi Mike,
Thanks for your reply and valuable time.
Currently I am going with the method1 (as specified above) so no problems.
Nathan
Mike HankeyPosted Jul 18, 2008, 5:39 PM
There are various types of memory streams, I'm sure what your wanting to do is possible, maybe with a binary stream??
Not sure and I'd hate to lead you on a goose chase. I used memory streams to a lesser extent in my ClipSpy+ application and I know the Clipboard uses them to some extent but??
Sorry can't help you more!
Mike
Nathan NZPosted Jul 16, 2008, 6:52 AM
Thank you Mike,
There were 2 methods to accomplish my task
1.Create the metafile and save it disk. Then use Shapes.AddPicture(filename) to insert it into word in desired location.
2.Create the memorystream for the metafile, copy it directly to WORD(I dont know how it is done) or put it on Clipboard and insert it using Paste Method.
I follwed the method 1 and got the solution. I was trying out for the 2 method and even now I am hanging around that.
Anyhow method 1 got Okeyd by the team(for time being).
Still if you have any Idea regarding method 2 please share. Can it be accomplished?
Thank you very much for your time Mike.
Mike HankeyPosted Jul 16, 2008, 12:45 AM
Try just using the Clipboard.SetImage() to do the paste and don't worry about it being a MetaFile. If I remember right it takes care of the formatting for you. I wrote a RichEditControl (See my article here) if you have any questions.
To bypass that problem in the RichTextControl I just copied the image to the Clipboard using the SetImage() method and pasted it into the control at the current location. Turns out that thats a WHOLE lot easier than wrestling with formats.
Sorry its taken so long to get back to you, evidently they don't notify you when you post a reply.
Good Luck,
Mike
Nathan NZPosted Jul 15, 2008, 12:51 AM
Thanks for the reply Mike.
My task is to export a metafile image displayed on the screen to MS WORD 2007.
Metafile image is displayed as MetafileNode(using syncfusion suite). I am using C# and Visual Studio Tools for Office to accomplish this. Through VSTO forums I came to know that metafile image can be stored in memory stream and can be pasted to word using the word.doc.Paste method. I copied metafile to clipboard with the command Clipboard.SetData(DataFormats.EnhancedMetafile, metanode.Image); // metanode.Image returns a Metafile Object
When I paste using Doc.ActiveWindow.Selection.paste() I get Command Failed Error (800A1066).
Where I am going wrong?
And is it possible tocopy and paste the metafile using memory(stream) without using Clipboard.
Waiting for early reply.
Mike HankeyPosted Jul 14, 2008, 7:41 PM
Need a little more information about what your doing and how your doing it. Language, code on how your attempting to do it, etc.. Something!
Mike
Nathan NZPosted Jul 14, 2008, 4:33 AM
Thanks Mike,
After googling and thru some forums I came to know that Clipboard can be used to export images to word. I was able to copy the images in clipboardbut while posting to word I am getting the exception as "Excetion occured due to no data in clipboard or the data is not correct". I suspect this is related to the DataFormat I am copying in the Clipboard but I dont know how to resolve it.
Any Ideas?
Mike HankeyPosted Jul 14, 2008, 12:51 AM
Meta files are not very well documented and when developing ClipSpy+ I omitted them because I couldn't find much help.
The ClipSpy+ application won't answer your problem but it is a tool you can use to do further investigation.
Mike