Hello,
Wanted to know if it's possible to use a Macro to Scale the image on a sheet to automatically resize when the excel program is large or small?
John
Hello,
Wanted to know if it's possible to use a Macro to Scale the image on a sheet to automatically resize when the excel program is large or small?
John
Last edited by jjfletcher; 05-16-2016 at 04:46 PM. Reason: SOLVED
Welcome to ExcelFox jjfletcher
What you have asked for is very much possible. There may be ways to hook the window using APIs, however if you want to do this using native VBA features in Excel, you will need to use Excel 2013 or above. The code below is just a sample to show you how this can be done in a rudimentary yet very effective way.
Code:Private Sub Workbook_WindowResize(ByVal Wn As Window) With ThisWorkbook.Sheets(1).Shapes(1) .Width = Wn.VisibleRange.Width .Height = Wn.VisibleRange.Height End With End Sub
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
Excellent - This works perfect... Thanks.... This is ok fro all Excel programs over 2013 - will need to focus on a solution for under 2013 versions.
Thanks Again....
Best Regards,
John
Share with us if you find anything for lesser versions of Excel.
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
Thanks Excel Fox,
I most certainly will send up if I find anything for lesser versions of Excel
John
Actually, your code works fine down to, at minimum, XL2003 (the earliest version I own)... sort of. There is a WindowsResize event in XL2003 and above, but the event only fires when the worksheet window is not maximized and your code works only when you resize a non-maximized worksheet window. Apparently, when the worksheet is maximized, it is a fixed size and resizing the workbook only exposes or hides portions of that maximized window.
Last edited by Rick Rothstein; 06-12-2016 at 06:57 AM.
Bookmarks