E
ExcelMonkey
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.XlPictureAppearance.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.XlPictureAppearance.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
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.XlPictureAppearance.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.XlPictureAppearance.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