Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Compress Pictures with VBA

Hi everbody,

I tried to compress pictures with a makro. If I do manually, format
graphic -- compress -- web/monitor 96 dpi, it works, but when I
record this with the makro recorder and play it, it doesen't work.
Here is the code which I record:

Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType =
msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#

So can anybody help me, how I can compress an image with VBA???

Thanks for your answers??

Micha

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Compress Pictures with VBA

Micha,
I have just changed to using XL2002. Recording a macro of compressing a
resized graphic gives output that contained nothing part from
ActiveSheet.Shapes("Picture 2").Select
So I'm not sure at the moment.

However, do you have a Picture selected before running the code, as you are
working the Selection object.

NickHK

"Micha" wrote in message
ps.com...
Hi everbody,

I tried to compress pictures with a makro. If I do manually, format
graphic -- compress -- web/monitor 96 dpi, it works, but when I
record this with the makro recorder and play it, it doesen't work.
Here is the code which I record:

Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType =
msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#

So can anybody help me, how I can compress an image with VBA???

Thanks for your answers??

Micha




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Compress Pictures with VBA

Micha,
I have just changed to using XL2002. Recording a macro of compressing a
resized graphic gives output that contained nothing part from
ActiveSheet.Shapes("Picture 2").Select
So I'm not sure at the moment.

However, do you have a Picture selected before running the code, as you are
working the Selection object.

NickHK

"Micha" wrote in message
ps.com...
Hi everbody,

I tried to compress pictures with a makro. If I do manually, format
graphic -- compress -- web/monitor 96 dpi, it works, but when I
record this with the makro recorder and play it, it doesen't work.
Here is the code which I record:

Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType =
msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#

So can anybody help me, how I can compress an image with VBA???

Thanks for your answers??

Micha





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Compress Pictures with VBA

Hi NickHK,

I start the record and selectcs one picture and he should do this for
every picture in the document, here is my complete code:

Sub bildEinfuegen()
Dim bild As Variant
Dim pfad As String
Dim i As Integer
Dim name As String
Dim orgHoehe As Double
Dim orgBreite As Double
Dim neueBreite As Double
Dim spalte As Integer

neueBreite = 10 'in cm
neueBreite = Application.CentimetersToPoints(neueBreite)
spalte = 1

pfad = "D:\Austausch\"

For i = 1 To 3
name = "DB2 V7_" & i & ".jpg"

bild = pfad & name
Cells(1, spalte).Select

ActiveSheet.Pictures.Insert(bild).Select


orgHoehe = Selection.ShapeRange.Height
orgBreite = Selection.ShapeRange.Width

Selection.ShapeRange.Width = neueBreite
Selection.ShapeRange.Height = orgHoehe * neueBreite / orgHoehe

.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType =
msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#

spalte = spalte + 3

Next i
End Sub


we are using Excel 2003

NickHK schrieb:

Micha,
I have just changed to using XL2002. Recording a macro of compressing a
resized graphic gives output that contained nothing part from
ActiveSheet.Shapes("Picture 2").Select
So I'm not sure at the moment.

However, do you have a Picture selected before running the code, as you are
working the Selection object.

NickHK

"Micha" wrote in message
ps.com...
Hi everbody,

I tried to compress pictures with a makro. If I do manually, format
graphic -- compress -- web/monitor 96 dpi, it works, but when I
record this with the makro recorder and play it, it doesen't work.
Here is the code which I record:

Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType =
msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 0#
Selection.ShapeRange.PictureFormat.CropRight = 0#
Selection.ShapeRange.PictureFormat.CropTop = 0#
Selection.ShapeRange.PictureFormat.CropBottom = 0#

So can anybody help me, how I can compress an image with VBA???

Thanks for your answers??

Micha


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you export pictures from my pictures file into a word docu Becky New Users to Excel 1 November 20th 09 07:02 PM
Compress Pictures function doesn't work? sestanzione Excel Discussion (Misc queries) 0 July 31st 09 07:26 PM
Some pictures did not compress DK Excel Discussion (Misc queries) 0 August 24th 07 03:12 PM
Pictures.Visible question (after adding many pictures, they stop disappearing) Abe[_4_] Excel Programming 2 July 11th 06 05:02 AM
Excel's Compress Pictures or deleting pictures doesn't seem work guidod Excel Discussion (Misc queries) 1 January 29th 06 06:51 AM


All times are GMT +1. The time now is 04:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"