View Single Post
 
Old 07-01-2014, 12:15 AM
tha_slughy tha_slughy is offline Windows 8 Office 2013
Novice
 
Join Date: Jul 2014
Posts: 3
tha_slughy is on a distinguished road
Exclamation Inserting and formatting photos in word 2013

Hello,

I have one problem, consisting of two issues. I use a lot of pictures in word reports, as to date in previous word versions I could easily process my pictures with a vba macro.

In order not to waste too much time I drag and drop the pictures in their required space, as an inlineshape and then resize these pictures to the required size.

As from word 2013 I noticed an oddity. The pictures which you drag and drop are sometimes inlineshape and sometimes not. As a result the macro not always works.

Moreover when the macro does work, it encounters different issues which I did not encounter in previous word versions.

To recap, the goal is to drop a photo (jpg) into a word document and be able to run a macro on it with a hotkey. The required actions are lock the aspect ratio, resize the width and fit the photo with a black solid border.

The current used macro is as follows:

Code:
Sub AfbeeldingImporteren()
'
' ResizeImage Macro
'
    Dim shape As InlineShape
    ' iterate all selected shapes
    For Each shape In Selection.InlineShapes
        ' remain aspect ratio
        shape.LockAspectRatio = msoTrue
        ' set width to 225 px
        newWidth = 225
        ' shape.Height = (newWidth / shape.Width) * shape.Height
        shape.Width = newWidth
        ' Add Borders
        Selection.InlineShapes(1).Line.Weight = 0.75
        Selection.InlineShapes(1).Line.DashStyle = msoLineSolid
        Selection.InlineShapes(1).Line.Visible = msoTrue
        Selection.InlineShapes(1).Line.ForeColor.RGB = RGB(0, 0, 0)
        
    Next

'
'
End Sub
All help resolving these two (probably connected) issues would be great!
Reply With Quote