简体   繁体   中英

Excel Camera Tool - Resize image to 100% scale

I am trying use an image to display different tables of data using the camera tool.

As a test the below code works,

  1. i change the shape formula to a new range, and then i update the shape scale as it doesn't automatically update when the data is on a different sheet

    2.This only works if i click the button twice. 1st click changes the source, but i have to click it a second time to get the scale to reset to 100%

Any ideas why this is?

Private Sub CommandButton1_Click()

Shapes("Display").DrawingObject.Formula = "=Pivots!AS2:BB10"
Shapes("Display").DrawingObject.ShapeRange.ScaleWidth 1, msoTrue
Shapes("Display").DrawingObject.ShapeRange.ScaleHeight 1, msoTrue

End Sub

Private Sub CommandButton2_Click()

Shapes("Display").DrawingObject.Formula = "=Pivots!AS13:BA27"
Shapes("Display").DrawingObject.ShapeRange.ScaleWidth 1, msoTrue
Shapes("Display").DrawingObject.ShapeRange.ScaleHeight 1, msoTrue

End Sub

DoEvents is like a magical incantation that I try when things like this happen. It usually doesn't help, but this time it did!

Private Sub CommandButton1_Click()

Shapes("Display").DrawingObject.Formula = "=Pivots!AS2:BB10"
DoEvents
Shapes("Display").DrawingObject.ShapeRange.ScaleWidth 1, msoTrue
Shapes("Display").DrawingObject.ShapeRange.ScaleHeight 1, msoTrue
End Sub

Private Sub CommandButton2_Click()

Shapes("Display").DrawingObject.Formula = "=Pivots!AS13:BA27"
DoEvents
Shapes("Display").DrawingObject.ShapeRange.ScaleWidth 1, msoTrue
Shapes("Display").DrawingObject.ShapeRange.ScaleHeight 1, msoTrue
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM