Cant "picture" Format from Clipboard to .bmp file type

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
 
E

ExcelMonkey

Come on throw me a bone. This is killing me. Why can't I save this as a
..bmp file when using the "XLpicture" format?

Thanks

EM
 
A

Andy Pope

Hi,

Make sure you have SP2 installed as not being able to copyas Bitmap was a
bug.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
ExcelMonkey said:
Come on throw me a bone. This is killing me. Why can't I save this as a
.bmp file when using the "XLpicture" format?

Thanks

EM

ExcelMonkey said:
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
 
E

ExcelMonkey

I am using XP and VS 2008. When you say SP2 do you mean for the XP
Operating System or for Visual Studio 2008?

Thanks

EM

Andy Pope said:
Hi,

Make sure you have SP2 installed as not being able to copyas Bitmap was a
bug.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
ExcelMonkey said:
Come on throw me a bone. This is killing me. Why can't I save this as a
.bmp file when using the "XLpicture" format?

Thanks

EM

ExcelMonkey said:
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
 
A

Andy Pope

Neither of those.

SP2 for Office 2007, which includes Excel 12.0

Cheers
Andy
I am using XP and VS 2008. When you say SP2 do you mean for the XP
Operating System or for Visual Studio 2008?

Thanks

EM

:

Hi,

Make sure you have SP2 installed as not being able to copyas Bitmap was a
bug.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Come on throw me a bone. This is killing me. Why can't I save this as a
.bmp file when using the "XLpicture" format?

Thanks

EM

:


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
 
E

ExcelMonkey

Let me get back to you on this.

Thanks

EM

Andy Pope said:
Neither of those.

SP2 for Office 2007, which includes Excel 12.0

Cheers
Andy
I am using XP and VS 2008. When you say SP2 do you mean for the XP
Operating System or for Visual Studio 2008?

Thanks

EM

:

Hi,

Make sure you have SP2 installed as not being able to copyas Bitmap was a
bug.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Come on throw me a bone. This is killing me. Why can't I save this as a
.bmp file when using the "XLpicture" format?

Thanks

EM

:


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
 
E

ExcelMonkey

No this didn't fix it. I didn't have SP2 installed in Office 2007. But
installing it still produces the same error:

"Object reference not set to an instance of an object."

on the line of code:

oImgObj.Save(FileCompareFolder & "\[" & xlBook.Name & "]" & xlSheet.Name &
".bmp", System.Drawing.Imaging.ImageFormat.Bmp)

And again this fails when I use the xlPrinter and xlPicture properties but
it works when I use the xlScreen and xlbitmap properties.

Thanks

EM

ExcelMonkey said:
Let me get back to you on this.

Thanks

EM

Andy Pope said:
Neither of those.

SP2 for Office 2007, which includes Excel 12.0

Cheers
Andy
I am using XP and VS 2008. When you say SP2 do you mean for the XP
Operating System or for Visual Studio 2008?

Thanks

EM

:


Hi,

Make sure you have SP2 installed as not being able to copyas Bitmap was a
bug.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Come on throw me a bone. This is killing me. Why can't I save this as a
.bmp file when using the "XLpicture" format?

Thanks

EM

:


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
 

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