Picture compression in Excel 2007 - works in 2003

W

Walt

Hi,

I've written an application to manage a club membership directory with
member pictures. Many of the pictures were taken with digital
cameras and are megabytes in size. These must be compressed. This
works in Excel 2003 but doesn't in Excel 2007.Sub CompressPics()
Dim StrtSel As Range
On Error GoTo CompressPicsERROR
Set StrtSel = Selection
With ActiveSheet
.Unprotect
.DrawingObjects.Select '<< The problem seems
to be here somehow
CommandBars.FindControl(ID:=6382).Execute
StrtSel.Select
.Protect
End With
Set StrtSel = Nothing
Exit Sub
CompressPicsERROR:
ActiveSheet.Protect
Set StrtSel = Nothing
MsgBox "ERROR in CompressPics Routine."
End Sub

Any help will be appreciated,
Walt
 
A

Andy Pope

Hi,

Try this in xl2007.

application.CommandBars.ExecuteMso "PicturesCompress"

Cheers
Andy
 
W

Walt

Hi Andy,

Thanks, that works just fine in Excel 2007. I tried using the
following routine, but when testing back in Excel 2003, I get an Error
message:

Microsoft Visual Basic
Compile Error:
Method or data member not found
OK & Help buttons

It's been a long time since I used conditional compile. Thinking
back to the compiler constants, that doesn't seem to be a way around
this. I hope to get 50+ copies of this application out to the club
sub-units (Our Oregon unit has 100+ members to track). And,
hopefully with the next release of Excel, those members with Macs will
be able to use it too without a lot of gyration.

Sub CompressPics()
Dim StrtSel As Range
On Error GoTo CompressPicsERROR
Set StrtSel = Selection
With ActiveSheet
.Unprotect
If Application.Version < 12 Then
.DrawingObjects.Select
Application.CommandBars.FindControl(ID:=6382).Execute
Else
.Shapes.SelectAll
Application.CommandBars.ExecuteMso "PicturesCompress"
'<< ExecuteMso highlighted on XL2003 compile error
End If
StrtSel.Select
.Protect
End With
Set StrtSel = Nothing
Exit Sub
CompressPicsERROR:
StrtSel.Select
ActiveSheet.Protect
Set StrtSel = Nothing
MsgBox "ERROR in CompressPics Routine."
End Sub

Thanks for the help.
Walt
 
A

Andy Pope

Try this modification when testing application version.

If Val(Application.Version) < 12 Then

Cheers
Andy
 
W

Walt

Hi Andy,

Well, that didn't seem to make any difference, though I can see it's
better syntax.

The root of the problem seems to be that for Excel 2003, I need
something that is not functional in Excel 2007 and in Excel 2007, and
I need something that didn't exist in Excel 2003. So, even though I
differentiate by version, Excel 2003 just won't compile with the
mechanism for Excel 2007. If there were an appropriate conditional
compile constant, I could probably make this work, but there isn't to
my knowledge.

I hate to run two versions of this, and maybe more when the next Mac
version of Excel is released, but I don't see a way around that. It
looks like that's what I'll have to do. The club members have all
sorts of machines with all sorts of Excel versions.

It's interesting to note that in Excel 2007 both the older and the
newer compress picture dialog boxes can be displayed using
1) Application.CommandBars.FindControl(ID:=6382).Execute - for the
old, and
2) Application.CommandBars.ExecuteMso "PicturesCompress" - for the
new
Only the new actually works.

It sure would be nice if there were a Method to do picture
compression.

Walt
 
A

Andy Pope

You will not get it to compile in xl2003 as you are using code that is
not recognised. Obviously newer versions can know about older versions,
so for compiling and least it's not a problem.

You can move the bits code version specific code in to separate routines
that you call from CompressPics routine. You will also need to set the
option to Compile on demand, vbe menu Tools > Options > General.

Cheers
Andy
 
W

Walt

Hi Andy,

THAT WORKS PERFECTLY -- THANK YOU!!

I've tested with Excel versions 2002, 2003 & 2007.

Walt
 
A

army perry

Walt,
I have been looking for an excel app to manage a directory
of 110 people with their pictures and contact info
would you be open to sharing your effort. I
would like to be able to publish it to a word or pdf file for people to download for reference and update when changes occur.

I have both XL 2003 and 2007



Walt wrote:

Picture compression in Excel 2007 - works in 2003
10-Feb-10

Hi

I have written an application to manage a club membership directory wit
member pictures. Many of the pictures were taken with digita
cameras and are megabytes in size. These must be compressed. Thi
works in Excel 2003 but does not in Excel 2007.Sub CompressPics(
Dim StrtSel As Rang
On Error GoTo CompressPicsERRO
Set StrtSel = Selectio
With ActiveShee
..Unprotec
..DrawingObjects.Select '<< The problem seem
to be here someho
CommandBars.FindControl(ID:=6382).Execut
StrtSel.Selec
..Protec
End Wit
Set StrtSel = Nothin
Exit Su
CompressPicsERROR
ActiveSheet.Protec
Set StrtSel = Nothin
MsgBox "ERROR in CompressPics Routine.
End Su

Any help will be appreciated
Walt

Previous Posts In This Thread:

Picture compression in Excel 2007 - works in 2003
Hi

I have written an application to manage a club membership directory wit
member pictures. Many of the pictures were taken with digita
cameras and are megabytes in size. These must be compressed. Thi
works in Excel 2003 but does not in Excel 2007.Sub CompressPics(
Dim StrtSel As Rang
On Error GoTo CompressPicsERRO
Set StrtSel = Selectio
With ActiveShee
..Unprotec
..DrawingObjects.Select '<< The problem seem
to be here someho
CommandBars.FindControl(ID:=6382).Execut
StrtSel.Selec
..Protec
End Wit
Set StrtSel = Nothin
Exit Su
CompressPicsERROR
ActiveSheet.Protec
Set StrtSel = Nothin
MsgBox "ERROR in CompressPics Routine.
End Su

Any help will be appreciated
Walt

Hi,Try this in xl2007.application.CommandBars.
Hi

Try this in xl2007

application.CommandBars.ExecuteMso "PicturesCompress

Cheer
And

On 11/02/2010 01:21, Walt wrote:

Hi Andy,Thanks, that works just fine in Excel 2007.
Hi Andy

Thanks, that works just fine in Excel 2007. I tried using th
following routine, but when testing back in Excel 2003, I get an Erro
message

Microsoft Visual Basi
Compile Error
Method or data member not foun
OK & Help button

it is been a long time since I used conditional compile. Thinkin
back to the compiler constants, that does not seem to be a way aroun
this. I hope to get 50+ copies of this application out to the clu
sub-units (Our Oregon unit has 100+ members to track). And
hopefully with the next release of Excel, those members with Macs wil
be able to use it too without a lot of gyration

Sub CompressPics(
Dim StrtSel As Rang
On Error GoTo CompressPicsERRO
Set StrtSel = Selectio
With ActiveShee
..Unprotec
If Application.Version < 12 The
..DrawingObjects.Selec
Application.CommandBars.FindControl(ID:=6382).Execut
Els
..Shapes.SelectAl
Application.CommandBars.ExecuteMso "PicturesCompress
'<< ExecuteMso highlighted on XL2003 compile erro
End I
StrtSel.Selec
..Protec
End Wit
Set StrtSel = Nothin
Exit Su
CompressPicsERROR
StrtSel.Selec
ActiveSheet.Protec
Set StrtSel = Nothin
MsgBox "ERROR in CompressPics Routine.
End Su

Thanks for the help
Walt

Try this modification when testing application version.If Val(Application.
Try this modification when testing application version

If Val(Application.Version) < 12 The

Cheer
And

On 11/02/2010 19:44, Walt wrote

-

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

Hi Andy,Well, that did not seem to make any difference, though I can see it
Hi Andy

Well, that did not seem to make any difference, though I can see it i
better syntax.

The root of the problem seems to be that for Excel 2003, I need
something that is not functional in Excel 2007 and in Excel 2007, and
I need something that did not exist in Excel 2003. So, even though I
differentiate by version, Excel 2003 just will not compile with the
mechanism for Excel 2007. If there were an appropriate conditional
compile constant, I could probably make this work, but there is not to
my knowledge.

I hate to run two versions of this, and maybe more when the next Mac
version of Excel is released, but I do not see a way around that. It
looks like that is what I will have to do. The club members have all
sorts of machines with all sorts of Excel versions.

it is interesting to note that in Excel 2007 both the older and the
newer compress picture dialog boxes can be displayed using
1) Application.CommandBars.FindControl(ID:=6382).Execute - for the
old, and
2) Application.CommandBars.ExecuteMso "PicturesCompress" - for the
new
Only the new actually works.

It sure would be nice if there were a Method to do picture
compression.

Walt

You will not get it to compile in xl2003 as you are using code that isnot
You will not get it to compile in xl2003 as you are using code that is
not recognised. Obviously newer versions can know about older versions,
so for compiling and least it is not a problem.

You can move the bits code version specific code in to separate routines
that you call from CompressPics routine. You will also need to set the
option to Compile on demand, vbe menu Tools > Options > General.

Cheers
Andy

On 13/02/2010 00:30, Walt wrote:

--

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

Hi Andy,THAT WORKS PERFECTLY -- THANK YOU!!
Hi Andy,

THAT WORKS PERFECTLY -- THANK YOU!!

I have tested with Excel versions 2002, 2003 & 2007.

Walt


Submitted via EggHeadCafe - Software Developer Portal of Choice
Break the Roles in SharePoint Lists
http://www.eggheadcafe.com/tutorial...7-42f2d9110d79/break-the-roles-in-sharep.aspx
 
W

Walt

Hi army perry,

The application was written for an Airstream travel trailer club
called WBCCI. The members are sensitive to having their contact data
distributed. I'll have to strip the data & most pictures to preserve
their confidentiality and parts of it are not likely to relate to your
membership. At the moment, I consider it a work in progress and it's
evolving as folks think of more functionalities they want. The
structure, centered on a flat file database, may be useful to you.
I'll look it over and, if practicable, post a stripped copy --
possibly in the next few days.

Walt Weber
 

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