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

The picture from XLSX file printed to PDF got...

You created the XLSX sheet, perfectly finetuned and images you used were set the Aspect-Ratio 1 x 1. All looks fine, until you perform the print to PDF file. At that moment everything is still fine in the sheet, but the Aspect Ratio of the same image in the resulting PDF file is now instead of the square the rectangle, wasting your intentions and time you spent.  

Did you considered the steps to fix it?

The fact is, that each image contained in the PDF printout from any EXCEL sheet, will got changed to a lower height no matter, how will be arranged the picture in the sheet before the printing to PDF. The trick, how to avoid distorted image dimensions in printout is following:  

Before sending the sheet to PDF printer, change the image height, and  increase it by 6 percents of original image height.  am. Sapien eget mi proin sed libero enim sed faucibus turpis.

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.