PC Review


Reply
Thread Tools Rate Thread

Clipboard images to Bitmap files through VBA in Excel

 
 
Elliot
Guest
Posts: n/a
 
      17th Sep 2008
This is an 'older' question (in that I know it's been asked before, but I'm
not sure anyone has ever answered it). Specifically I'm looking for a
workbook example that allows a user to take whatever has most recently been
copied into the clipboard and save that as a BMP image (ie. with a .bmp
extension, not jpeg or gif or png formatted) using VBA.

Lebans has some older code posted on-line, but I can't get it to work. It
might be that I haven't added all the necessary references, but I am
including the OLE reference that he suggests - again no dice.

Please assist,
Thanks
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      17th Sep 2008
Everything you need is in Stephen Bullen's PastePicture.Zip here

http://www.oaltd.co.uk/Excel/Default.htm

Regards,
Peter T


"Elliot" <(E-Mail Removed)> wrote in message
news:8A7D4F34-04EE-4530-9861-(E-Mail Removed)...
> This is an 'older' question (in that I know it's been asked before, but
> I'm
> not sure anyone has ever answered it). Specifically I'm looking for a
> workbook example that allows a user to take whatever has most recently
> been
> copied into the clipboard and save that as a BMP image (ie. with a .bmp
> extension, not jpeg or gif or png formatted) using VBA.
>
> Lebans has some older code posted on-line, but I can't get it to work. It
> might be that I haven't added all the necessary references, but I am
> including the OLE reference that he suggests - again no dice.
>
> Please assist,
> Thanks



 
Reply With Quote
 
Elliot
Guest
Posts: n/a
 
      17th Sep 2008
Doesn't seem to be working in Excel 2007 (ok in 2003, but I don't get any
result returned for oPic - Paste Picture function doesn't seem to be working
in 2007).



"Peter T" wrote:

> Everything you need is in Stephen Bullen's PastePicture.Zip here
>
> http://www.oaltd.co.uk/Excel/Default.htm
>
> Regards,
> Peter T
>
>
> "Elliot" <(E-Mail Removed)> wrote in message
> news:8A7D4F34-04EE-4530-9861-(E-Mail Removed)...
> > This is an 'older' question (in that I know it's been asked before, but
> > I'm
> > not sure anyone has ever answered it). Specifically I'm looking for a
> > workbook example that allows a user to take whatever has most recently
> > been
> > copied into the clipboard and save that as a BMP image (ie. with a .bmp
> > extension, not jpeg or gif or png formatted) using VBA.
> >
> > Lebans has some older code posted on-line, but I can't get it to work. It
> > might be that I haven't added all the necessary references, but I am
> > including the OLE reference that he suggests - again no dice.
> >
> > Please assist,
> > Thanks

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      17th Sep 2008
I meant for you to extract the relavant APIs and code and adapt for your
needs.

Drag modPastePicture from PastePicture.xls into your project, add another
module with the following

' Save image in the clipboard (if any)
' requires modPastePicture from Stephen Bullen's PastePicture.xls
' to test press (Alt or Ctrl) PrtScn before running
Sub SaveClipboardBMP()
Dim vFile As Variant
Dim sFilter As String, lPicType As Long
Dim oPic As IPictureDisp

On Error Resume Next
Set oPic = PastePicture(xlBitmap)
On Error GoTo 0

If oPic Is Nothing Then
MsgBox "no image in clipboard"
Else
sFilter = "Windows Bitmap (*.bmp),*.bmp"
vFile = Application.GetSaveAsFilename( _
initialfilename:="", filefilter:=sFilter)
If vFile <> False Then
SavePicture oPic, vFile
End If
End If
End Sub

Regards,
Peter T


"Elliot" <(E-Mail Removed)> wrote in message
news:CCA52856-94AF-40AB-839B-(E-Mail Removed)...
> Doesn't seem to be working in Excel 2007 (ok in 2003, but I don't get any
> result returned for oPic - Paste Picture function doesn't seem to be
> working
> in 2007).
>
>
>
> "Peter T" wrote:
>
>> Everything you need is in Stephen Bullen's PastePicture.Zip here
>>
>> http://www.oaltd.co.uk/Excel/Default.htm
>>
>> Regards,
>> Peter T
>>
>>
>> "Elliot" <(E-Mail Removed)> wrote in message
>> news:8A7D4F34-04EE-4530-9861-(E-Mail Removed)...
>> > This is an 'older' question (in that I know it's been asked before, but
>> > I'm
>> > not sure anyone has ever answered it). Specifically I'm looking for a
>> > workbook example that allows a user to take whatever has most recently
>> > been
>> > copied into the clipboard and save that as a BMP image (ie. with a .bmp
>> > extension, not jpeg or gif or png formatted) using VBA.
>> >
>> > Lebans has some older code posted on-line, but I can't get it to work.
>> > It
>> > might be that I haven't added all the necessary references, but I am
>> > including the OLE reference that he suggests - again no dice.
>> >
>> > Please assist,
>> > Thanks

>>
>>
>>



 
Reply With Quote
 
j
Guest
Posts: n/a
 
      17th Nov 2008
Hi Elliot

did you find a solution for this? I get similar issues when using Win API
Clipboard method GetClipboardData - there are no BMP types on the Windows
clipboard (enum=2) following Paste of any kind from VBA?

cheers!



"Elliot" wrote:

> Doesn't seem to be working in Excel 2007 (ok in 2003, but I don't get any
> result returned for oPic - Paste Picture function doesn't seem to be working
> in 2007).
>
>
>
> "Peter T" wrote:
>
> > Everything you need is in Stephen Bullen's PastePicture.Zip here
> >
> > http://www.oaltd.co.uk/Excel/Default.htm
> >
> > Regards,
> > Peter T
> >
> >
> > "Elliot" <(E-Mail Removed)> wrote in message
> > news:8A7D4F34-04EE-4530-9861-(E-Mail Removed)...
> > > This is an 'older' question (in that I know it's been asked before, but
> > > I'm
> > > not sure anyone has ever answered it). Specifically I'm looking for a
> > > workbook example that allows a user to take whatever has most recently
> > > been
> > > copied into the clipboard and save that as a BMP image (ie. with a .bmp
> > > extension, not jpeg or gif or png formatted) using VBA.
> > >
> > > Lebans has some older code posted on-line, but I can't get it to work. It
> > > might be that I haven't added all the necessary references, but I am
> > > including the OLE reference that he suggests - again no dice.
> > >
> > > Please assist,
> > > Thanks

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap from Clipboard back to Clipboard as PNG? Joe Duchtel Microsoft VB .NET 20 9th Jun 2008 07:40 PM
Transfer clipboard from Task pane clipboard(office?) content to Excel (windows?) clipboard? tskogstrom Microsoft Excel Programming 2 6th Mar 2007 12:50 PM
Can't get bitmap from the clipboard =?Utf-8?B?Y2h1Y2sgcnVkb2xwaA==?= Microsoft Dot NET 0 20th Dec 2005 12:02 AM
Help when saving images to bitmap files =?Utf-8?B?TSBLZWV0b24=?= Microsoft VB .NET 1 14th Nov 2005 09:17 PM
Get bitmap from clipboard problem Christopher Bailey Microsoft Dot NET Framework Forms 0 2nd Dec 2004 09:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.