View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ExcelMonkey ExcelMonkey is offline
external usenet poster
 
Posts: 553
Default Cant "picture" Format from Clipboard to .bmp file type

This actually being done in VB.Net. But I am using hte Excel 12.0 object
model. I could not get an answer in the VSTO/VB forums and thought maybe I
could get it here. Note as this is in VB I am using Excel enumerations but
it is essentially VBA.

I can do the following in VB:

xlSheet.UsedRange.CopyPicture(Excel.XlPictureAppea rance.xlScreen,
Excel.XlCopyPictureFormat.xlBitMap)
'Copy Image from Clipboard to temp folder
Dim oImgObj As Image = Clipboard.GetImage
oImgObj.Save(FileCompareFolder & "\[" & xlBook.Name & "]" & xlSheet.Name &
".bmp", System.Drawing.Imaging.ImageFormat.Bmp)

However when I change the first line to (note the underlined portion)
xlSheet.UsedRange.CopyPicture(Excel.XlPictureAppea rance.xlPrinter ,
Excel.XlCopyPictureFormat.xlPicture )

I get the following error message:"Object reference not set to an instance
of an object." on the line:
oImgObj.Save(FileCompareFolder & "\[" & xlBook.Name & "]" & xlSheet.Name &
".bmp", System.Drawing.Imaging.ImageFormat.Bmp)

Why is this? When I do this manually by copying ot clipboard and saving in
Paint I can use the bmp extension.

Thanks

EM