Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Excel CopyPicture and asve to Enhanced Metafile

$
0
0

Hi,

In excel I select a range and copy it as Picture. I have tried to paste it in Word and it works, but as soon as I want to save it as Enhanced Metafile I always get a null reference.

here is my code:

 private void CreateImageFile(string fileName)
        {
                if (Clipboard.ContainsData(System.Windows.DataFormats.EnhancedMetafile))
                {
                     Metafile metafile = Clipboard.GetData(System.Windows.DataFormats.EnhancedMetafile) as Metafile;
                     try
                     {
                         metafile.Save(fileName);
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.ToString());
                     }
                }

Hope you can help me.

Kind regards

Alex


Viewing all articles
Browse latest Browse all 31927

Trending Articles