How to fix that uggly bug in picture PDFing?

It is long-time existing issue, whith printing the sheets containing the pictures from Microsoft Excel. So far it is not fixed. Therefore, here is a workaround for your VBA codes.

EXCEL image height splatted on PDF printout

Now what? I need to automate that

OK, so consider the situation mentioned, and let's create an easy code in macro, that will perform following steps as expected.

  • Enumerate picture objects in your sheet.
  • Get the name of the last picture, the one, you would like to change the dimensions of.
  • Select the picture using previously found picture object's name.
  • Disable Aspect Ratio lock, so it is possible to adjust the height and width as well, having your custom dimensions.
  • Now, because picture objects uses points and percentages, change the picture's height by 6%. It means, you will improve the dimension by 1.06.
  • Perform all the tasks you need before printing to the PDF file, so it looks well.
  • Now, revert the height to its previous value in sheet, so the dimension of the picture is again square with same dimensions for width and height.