+ Reply to Thread
Results 1 to 3 of 3

Resizing Images Brought in Through VBA (Solved)

  1. #1
    Registered User
    Join Date
    06-18-2019
    Location
    Regina, Sask
    MS-Off Ver
    Microsoft Office 365 Business
    Posts
    3

    Resizing Images Brought in Through VBA (Solved)

    I am trying to set it up so that if a user checks a check box, it makes a sheet visible and inserts an image, scaled to fit within a certain area. It works just fine for any image that is landscape oriented where the height is 75% of the width (or less). But when I insert a portrait image I am having issues. At first it was making it too tall, so I adjusted the code to account for the height (and then center the image in the viewport), but now the portrait images lose their aspect ratio and look distorted. I have ShapeRange.LockAspectRatio = msoTrue, so it shouldn't be able to alter the aspect ratio, right?

    Here is the code I have so far.

    Please Login or Register  to view this content.
    What am I missing here? Thanks!!
    Last edited by DaveC3BI; 07-02-2019 at 11:07 AM. Reason: Solved the issue

  2. #2
    Registered User
    Join Date
    06-18-2019
    Location
    Regina, Sask
    MS-Off Ver
    Microsoft Office 365 Business
    Posts
    3

    Re: Resizing Images Brought in Through VBA

    I just want to bump this, since it went unanswered yesterday and probably won't get noticed if I leave it on the 3rd page (and falling)...

  3. #3
    Registered User
    Join Date
    06-18-2019
    Location
    Regina, Sask
    MS-Off Ver
    Microsoft Office 365 Business
    Posts
    3

    Re: Resizing Images Brought in Through VBA (Solved)

    Well I figured out my problem. I figured I should put the solution here in case anyone else ever has this issue and searches for it...

    I had hidden all cells outside of the formatted area of the output worksheets. When you hide the cells, even if the lockaspectratio is set to True, an image height or width will be shrunk to fit the space. Once the aspect ratio is distorted, there didn't seem to be a way change it back... So I unhide the extra empty cells. I also simplified my code to look like this:

    Please Login or Register  to view this content.
    Basically, I insert the picture full size to ensure the aspect ratio holds true. Then I check to see if the width or the height will fill the required range (basically to check portrait vs landscape). If the width will fill the range, I change the width to the max (577.5), then center the image vertically. If instead the height will fill the range, then I set the height to the max (345) then center the image horizontally.

    Hope this helps.
    Last edited by DaveC3BI; 07-02-2019 at 11:20 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Data Lookup & Brought Up
    By waheed254 in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 01-28-2014, 03:43 AM
  2. Cell value brought back from the end ot a table
    By raphiduani in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-18-2012, 04:10 AM
  3. Data from tables to be brought on sheet
    By beseda2004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2012, 07:02 PM
  4. Data from tables to be brought on sheet
    By beseda2004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2012, 08:50 AM
  5. Can a Message box be brought up in the middle of code asking for criteria?
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-04-2009, 11:14 AM
  6. Inventory Brought Foward
    By jvq in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-16-2006, 01:15 AM
  7. [SOLVED] kill formatting brought over from reports
    By widman in forum Excel General
    Replies: 2
    Last Post: 01-06-2006, 12:00 PM
  8. Comumn Series Brought to Front
    By Phil Hageman in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-24-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1