Extracting BMP from file

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
something like this
Code:
[COLOR=#000000][FONT=verdana]Function thumbCDR(file$) As StdPicture
   Dim tmp$, hF&, s$, base&, wd As Byte, ht As Byte, bpp%, thLen&, ofs&, thumb As String * 30000, b4&, th1&
   On Error Resume Next
   
   hF = FreeFile()
   Open file For Binary Access Read Shared As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] : If Err.Number Then Exit Function
   Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , thumb
   base = InStr(1, thumb, "DISP")
   If base <= 0 Or base > 15000 Then Exit Function
   Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , base + 16, wd
   Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , base + 20, ht
   Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , base + 26, bpp
   Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , base + 32, thLen
   Close
   ofs = &H36 + Switch(bpp = 1, 2 * 4, bpp = 4, 16 * 4, True, 256 * 4)
   th1=&H436 + CLng(ht) * CLng(wd):if th1>30000 then th1=30000
   thLen = iif(thLen + ofs<th1,thLen + ofs, th1)
   
   tmp = Environ("temp") + "thumb" + Hex$(Timer) + ".bmp"
   Open tmp For Binary Access Write Lock Read Write As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] : If Err.Number Then Exit Function
   s = "BM": Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , s      ' 2 bytes
   Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , thLen            ' 4 bytes
   Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , b4               ' 4 bytes zero
   Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , ofs              ' 4 bytes
   Put [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hF]#hF[/URL] , , Mid$(thumb, base + 12, thLen - 14)
   Close
   Set thumbCDR = LoadPicture(tmp)
   Kill tmp
   End Function[/FONT][/COLOR]
then assigning it to VBA form image object:
Code:
Code:
set Image1.picture=thumbCDR("c:\work\myDesign.cdr")[/FONT][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top