Macro to crop and resize images in Word(Windows)


This article is mostly intended for users of Ekahau Site Survey Pro generating report documentation.

I encourage you to clean-up, manipulate and prepare your floor plans before importing them into Ekahau. This will save you from a headache when it comes to report-writing time. Image manipulation is much easier before we create the Ekahau project.


Main Attraction

We have all been there… right?

The survey is complete, we have looked through and analysed the collected data. It’s time to smash out that report document, only, the coverage map visualisations have a ton of white space surrounding them and the floor plan is minuscule in the centre of the page.

It’s a PITA, but, by creating a macro within Word we can automate (and dramatically speed up) the image cropping and resize actions. This time the instructions are written for Word on Windows.

  1. Create and run your Ekahau report template
  2. File > Options > Advanced > Display
    Show measurements in units of to: Points
  3. OK
  4. (In the Ribbon) View > Macros > View Macros
  5. Type “CropAndResize” into the Macro Name field
    Click “Create”
  6. We are now in the MSWord Visual Basic Editor
    Copy and paste the VBA script below in the editor in between the lines of Sub “CropAndResize” and “EndSub”
    Commented out lines within VBA scripts begin with ‘’’

    ' This macro crops and resizes images
    ' The units are 'points'
    Dim oILS As InlineShape
    Set oILS = Selection.InlineShapes(1)
    With oILS
    .PictureFormat.CropLeft = 100
    .PictureFormat.CropTop = 100
    .PictureFormat.CropRight = 100
    .PictureFormat.CropBottom = 100
    End With
    With oILS
    .LockAspectRatio = True
    ' .Height = 260
    ' .Width = 450
    End With
    Exit Sub
  7. Click “Save” in the top-left
  8. You may get an error message, click “cancel”
  9. Save the Document / Macro into the special “.docm” format
  10. Once the macro is saved and we are returned to looking at the Word document
    Create a shortcut for the macro
    File > Options > Customise Ribbon
    At the bottom of the screen select Keyboard Shortcuts “Customise”
    Scroll down through the categories (on the left) to Macros
  11. Make sure the Macro Name is visible and selected in your Macros box (on the right)
  12. Assign a keyboard combo of your choosing in ‘Press new shortcut key:’
    Click “Assign”
    Then you can close the Options windows
  13. Test the macro on an image
    by selecting the image and using the newly created keyboard shortcut
  14. Please Note: The crop values used by this macro are absolute! Running the macro a second time will not affect the image cumulatively.
  15. If the crop amount is not sufficient, we need to go back to the macro and make some changes.
  16. (In the Ribbon) View > Macros > View Macros
  17. This time, all we need to do is alter the crop values
    Once complete
    Save in the top left
    Close the window
  18. Run the macro again using your shortcut


The macro can also be used to resize the image.

  • To define the width or height using the macro, remove the apostrophe ‘ from the appropriate line width or height and set the value in points
  • If you are unsure what the point value should be, consider cropping an image using the macro, resizing the image manually, observe the resulting width/height from (ribbon) Format

The macro will need to be applied to each image that requires manipulation, depending on your project, you may need to alter the macro for different shape floors within your report output.

When designing your report template, you can use the visualisation tag:

<#"visualization": {"resolution-width": "-1"}#>

This tag sets the resolution of the rendered visualization. Unit is in pixels. This tag is often used to reduce the resolution and save space in the resulting generated report…
That is NOT what we are doing here, set to negative 1, to force use the original resolution of the map image.

This should allow you to crop and enlarge the image within Word without it becoming grainy.

If you are working on macOS, I suggest this version of the article:
Macro to crop and resize images in Word(macOS)

Big thanks to Ameya Ramadurgakar for helping me with the Windows instructions.

Credit goes to Numerous Google search results for this solution, including this forum post

I hope you found these instructions reasonably easy to follow, if you did? Great, let me know. Twitter: @nickjvturner
If not, please comment below with recommendations.

1 thought on “Macro to crop and resize images in Word(Windows)

  1. […] If you are working on Windows, I suggest this version of the article: Macro to crop and resize images in Word(Windows) […]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: