April 2006
Beginner
1114 pages
98h 16m
English
graphic.LockAspectRatio [= setting]
True retains the aspect ratio when the height or width is set; False stretches or squashes the image to match the height or width settings. The following code demonstrates the result of both settings; notice that the image filename must be reset to restore the original proportions after resizing the image:
Sub GraphicAspectRatio( )
Dim gr As Graphic
' Add the footer image.
ActiveSheet.PageSetup.CenterFooterPicture.Filename = _
ThisWorkbook.Path & "\wombatright.bmp"
ActiveSheet.PageSetup.CenterFooter = "&G"
' Get the graphic object.
Set gr = ActiveSheet.PageSetup.CenterFooterPicture
' Squash the image (height stays the same)
gr.LockAspectRatio = False
gr.Height = 20
ActiveSheet.PrintOut , , , True
' Restore the footer image.
ActiveSheet.PageSetup.CenterFooterPicture.Filename = _
ThisWorkbook.Path & "\wombatright.bmp"
' Scale image to this width
gr.LockAspectRatio = True
gr.Height = 20
ActiveSheet.PrintOut , , , True
End SubRead now
Unlock full access