Compressing Pictures with Code

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
I have searched high and low and I havent been able to get any VBA code which will compress pictures.

A lot of the posts over t'internet say that it will come in a future version. These post were years old... so is it here yet?

Does anyone know the code to compress pictures in Excel 2007

Recording a macro doesnt pickup the compression parts

Any help would be appreciated


Regards
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
What do you mean by "compress". If you just want to change the size, change the height and width of the picture.
 
Upvote 0
compress - Under Picture Tools, on the Format tab, in the Adjust group, click Compress Pictures.

This action doesnt appear to be picked up when recording code in VBA
 
Upvote 0
Post is old so you have solved it fully by now ??? if not try

Function FileThereThere%(Ff$, ft$, DeleteFileTo As Boolean)
Dim ftt%, Fofso As Scripting.FileSystemObject
'need scripting reference
Set Fofso = CreateObject("Scripting.FileSystemObject")
If Fofso.FileExists(Ff) Then ftt = 2
If Fofso.FileExists(ft) Then
If DeleteFileTo Then
Fofso.DeleteFile (ft)
Else
ftt = ftt + 1
End If
End If
FileThereThere = ftt
'0 none 1, file to , 2 file from, 3 both
' 00 01 10 11
Set Fofso = Nothing
End Function

Sub WiaResizeTry(Ff$, ft$, mw%, mh%, DeleteFileTo As Boolean)
' parmeters ff FileFrom ft Fileto mw min width mh min height
'Delete file to to delete before copping or abandon copy

'MsgBox Ff & " " & ft & " " & DeleteFileTo

If FileThereThere(Ff, ft, DeleteFileTo) = 2 Then '
Dim Img 'As ImageFile
Dim IP 'As ImageProcess
'needs wia in references does not move people tags
icon9.gif
?
Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
On Error GoTo skipit
Img.LoadFile Ff$
IP.Filters.Add IP.FilterInfos("Scale").FilterID
IP.Filters(1).Properties("MaximumWidth") = mw
IP.Filters(1).Properties("MaximumHeight") = mh
Set Img = IP.Apply(Img)
Img.SaveFile ft
skipit:
Set Img = Nothing
Set IP = Nothing
End If
End Sub

'You will then need to use something like exiftool to move people and their rectangles if you want WLPG beta type people faces
 
Upvote 0

Forum statistics

Threads
1,213,556
Messages
6,114,284
Members
448,562
Latest member
Flashbond

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