#1
|
|||
|
|||
Creating an Image Formatting Macro
Hi,
I'd like to create what I believe to be a fairly complex macro in word. I've tried doing it manually using the Record Macro function but given it involves images it doesn't appear to be working. The basic steps are: 1) Convert the image from whatever format it is into a JPEG or any other image format that is suitable for compression (to do this manually I simply cut the image and then Special Paste and select the appropriate format). I am usually pasting in from the snipping tool which produces and output format unsuitable for compression. 2) Compress the image so that its size dimensions are reduced. 3) Apply a solid border with 2 1/4 point thickness. Can anyone offer a solution? Thanks in advance. Jay |
#2
|
||||
|
||||
You could use something along the lines of:
Code:
Sub Demo() Dim t As Single, l As Single, tRel As Single, lRel As Single With Selection If .InlineShapes.Count = 1 Then .InlineShapes(1).Range.Cut .PasteSpecial DataType:=15 .End = .End + 1 With .InlineShapes(1).Borders .Enable = True .OutsideLineStyle = wdLineStyleSingle .OutsideLineWidth = wdLineWidth225pt .OutsideColorIndex = wdBlack End With ElseIf .ShapeRange.Count = 1 Then With .ShapeRange(1) tRel = .TopRelative t = .Top lRel = .LeftRelative l = .Left .Anchor.Cut End With .PasteSpecial DataType:=15 .End = .End + 1 With .InlineShapes(1).Borders .Enable = True .OutsideLineStyle = wdLineStyleSingle .OutsideLineWidth = wdLineWidth225pt .OutsideColorIndex = wdBlack End With .InlineShapes(1).ConvertToShape With .ShapeRange(1) .TopRelative = tRel .Top = t .LeftRelative = lRel .Left = l End With End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hey macropod,
Thanks so much. With regard to size dimensions, I will be resizing the images manually to the size I want them before I execute the Macro. I'll then use the Macro to lock the dimensions is place using compression. If I paste the images to another application outside of word without compression the image will return back to its original dimensions. Having said that, will the Macro as you've posted it still function correctly? Thanks, Jay |
#4
|
||||
|
||||
The macro I posted simply copies the image then pastes it back into the document as a jpg with the same dimensions it already had - then applies the desired border. It makes no difference whether you compress the image before, or after, running the macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Thanks again macropod,
It works well, I'm very happy with it. I simply created a new toolbar section with the macro shortcut and the compress picture shortcut so its all fairly self-contained and efficient. Can I ask one more favour? Can you replicate the same function but without the image bordering? I've since realised that some images I would like a border, and some I wouldn't. I tried to edit the macro myself but I had problems. When I tried to change the name from Demo to something else to distinguish it, it didn't seem to like it. Thanks, Jay. |
#6
|
||||
|
||||
All you need for that is to make a copy of the macro & change 'Demo' on the copy to something else, then delete the two 'With .InlineShapes(1).Borders ... End With' blocks.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Worked a treat.
Once again thanks for your support. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bizarre problem with page background image when creating pdf | dbltapp | Word | 0 | 06-04-2015 04:57 PM |
URGENT!!! Powerpoint Image Formatting and Positioning Macro | mertulufi | PowerPoint | 5 | 12-20-2011 10:14 AM |
creating border to image without surrounding text | gib65 | Drawing and Graphics | 5 | 08-15-2011 09:17 AM |
Problem creating link to image file | leftylee | PowerPoint | 1 | 04-14-2010 05:49 AM |
Creating An Image Contact Sheet Template | skoz55 | Drawing and Graphics | 0 | 08-06-2009 10:39 PM |