If Not Intersect(rngPic, Range(shpPic.TopLeftCell, shpPic. 'Subtract 2 from width and height to ensure that picture _ '.LockAspectRatio = True 'Can be True or false 'Resize the picture to the width of the required range area Set shpPic = (Filename:=strPath & strFile, _ 'Setting Width and Height to -1 retains picture current dimensions 'and not marginally adjusted to cell outside the range.Ĭall DeleteExistPicture(rngPicArea) 'Delete existing picture from range (If exists) 'Adding 1 to the Left and Top ensures that the picture is within the range 'DropDown options must exactly match picture file names 'strpath = "C:\Users\OssieMac\Documents\Excel\Pictures\" 'Alternative example to previous line to set path other than ThisWorkbook StrPath = ThisWorkbook.Path & "\Pictures\" 'Edit to you path to the pictures Set rngPicArea = Range("G4:J9") 'Edit to required range for picture 'Following line: Edit "$B$2" to cell address of DropDown Private Sub Worksheet_Change(ByVal Target As Range)
#How to compress picture in word using vba free#
If you need more help then please feel free to get back to me but I will need more information on exactly what you require.
#How to compress picture in word using vba code#
You will need to edit the code where indicated with the comments. Do NOT change the sub name or it will not work as event code. Present at the llocation then it deletes it first and replaces with the selected picture.Įvent code is installed by right clicking on the worksheet tab name and select View code which opens the module attached to the specific worksheet. Copy and paste the code into the VBA editor. It adjusts the dimensions of the picture to a given range area on the worksheet.
![how to compress picture in word using vba how to compress picture in word using vba](https://wellsr.com/vba/assets/images/2021-12-10-vba-range-find.png)
The required picture is selected in a DropDown on the worksheet. The following code is an event code example that inserts a picture at a given location. If I can humbly offer up any assistance with some issues I have worked through please feel free to post.What do you mean by "Compress"? Do you mean to reduce the saved size Byrtes or to reduce the dimentions of the picture to fit in a given area on the worksheet? This will serve to significantly clean up that process. The compress images challenge has been a relative "hack" compared to other functionality I am delivering. Your code works flawlessly and also eliminates some other hoops I was jumping through. MsgBox "Error: " & Err.Number & " " & Err.Description Set oSh = Module3.GetShapeTaggedWith("picture", "fake", oSlide)Ī = ppAlertsNone Set oSlide = ActivePresentation.Slides("chartmanage") Keep in mind I was artificially selecting an image tagged as "picture"\"fake" to gain access to the menu items needed. I replaced the send key logic I had implemented which was not nearly as clean. I am grateful you took the time to post your suggestion. You may need to change %A (Alt+a)and %W (Alt+W) to other keys to navigate the dialogbox.Ī(Id:=6382).Execute The following code works in PPT 2003 english version. I think sendkeys is the best solution together with FindControl. Btw, the end game is too optimize file size reduction. Major gold star for anyone who can help me find a good solution.
![how to compress picture in word using vba how to compress picture in word using vba](https://support.content.office.net/en-us/media/ace5396e-7a6a-472d-bc00-41360589c39d.png)
I have done some research and this is evidently a tough issue. The best idea I have read so far is to utilize "send keys" but this has serious challenges as well.
![how to compress picture in word using vba how to compress picture in word using vba](https://i.ytimg.com/vi/-_mcJIuPJ2g/maxresdefault.jpg)
I have tried using macro record to see how powerpoint would reflect the steps and the resulting macros is blank. I need to deliver the same functionality for compressing pictures which can be achieved by doing the following: I am offering all automation via objects (buttons, text fields, etc) which are visible when in View Show Mode. I am delivering a polwerpoint presentation to a large sales force. Pictures are often cropped to focus attention on a particular area.). Note Selecting the Delete cropped areas of pictures check box discards the parts of the picture that were hidden during cropping (crop: To trim vertical or horizontal edges of an object. Under Picture Tools, on the Format tab, in the Adjust group, click Compress Pictures button: 3. Otherwise, click one picture so that Word makes the Picture Tools section of the Ribbon available. Note If you do not see the Picture toolbar, point to View, then point to Toolbars, and then click Picture. If you want to compress only one picture, select it. To display a toolbar, click Customize on the Tools menu, and then click the Toolbars tab.), click Compress Picture.