Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboa

T

TC

Hello,

Here is what I'm trying to do:

-- Make sure both MS Excel and MS Word are running
-- Create an Excel chart
-- Save the Excel file
-- Copy the Excel chart onto the clipboard using Ctrl + C
-- Go to Word and look under Edit > Paste Special
-- Note there is a source reference and an option to paste the chart as a
metafile, etc.
-- I would like to take this same information and make it available in a C#
or VB.Net app

For example, create a simple Windows application with a userform, an image
control, a label and a single command button.

Let's say that after the Excel chart is on the clipboard, one clicks the
Windows application command button and Voila!, the imate control now
contains a copy of the Excel chart and the label contains the reference
information.

I can make this work utilizing older technologies (i.e. WIN API to access
the clipboard, etc.).

Using the WIN32 API, there is a clipboard format called "OwnerLink".
Similarly to the .Net clipboard, one would register this format, check for
it on the clipboard and then retrieve using several API calls.

There are also clipboard formats called "Link Descriptor" and "Object
Descriptor" under WIN32.

It appears that, under .Net, there are currently no methods or
properties available to extract a source reference when a user places an
Office object / graphic on the clipboard.

If there is a workaround, by all means, please share.

Any assistance would be appreciated.

Best Regards,

Todd
 
S

sprungli

Hi Todd,

I ran into similar problems not longtime ago. You are looking for something
rather specific in the managed COM API that might simply not be there. I had
this kind of experience with the Word object model: some features exist in
VBA and not in the respective .NET wrappers, at least I was not able to find
them. So if you have already invested a lot of time and effort developing a
managed solution, keep searching in Microsoft.Office.Core, VBIDE libraries
and in Excel and Word PIAs. Also, although I lost the links, you can easily
find in MSDN the following articles:

- Tips and Tricks: Building Microsoft Office Add-ins with Visual C# .NET and
Visual Basic .NET
- Creating Office Managed COM Add-Ins with Visual Studio .NET
- HOW TO: Build an Office COM Add-in by Using Visual C# .NET
- HOWTO: Use Automation to Get and to Set Office Document Properties with
Visual C# .NET
- Working with the Office XP Primary Interop Assemblies
- Deployment of Managed COM Add-Ins in Office XP

Otherwise, you can always wrap your managed logic in a CCW, to which in turn
you can talk from any Office application. This is what I opted for after
spending more hours searching the managed APIs than actually writing code.

Good luck with your project.
 

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