Resizing an Image using VBA

Puppies72

Board Regular
Joined
Mar 29, 2010
Messages
211
Hi all,

I use the macro below (cobbled together from recorded macros) to copy an image (generated from linked autoshapes), export it to a new workbook, attempt to resize it so that it exactly fills one page, and then save as...(will be saved as a pdf)

however the resize doesn't seem to be working can anyone highlight a better way to resize the image - it copies over as a 9 page image but I need it to be a single full page with no margins.

Many thanks - code below

Code:
Sub ExportMap()
Dim wb As Workbook
    Dim rng As Range
 
    Set rng = ActiveWorkbook.ActiveSheet.Range("A1:Z123")
    Set wb = Workbooks.Add
 
    rng.Copy
    wb.ActiveSheet.Pictures.Paste
    Application.CutCopyMode = False
    ActiveWindow.View = xlPageBreakPreview
    ActiveSheet.Shapes.Range(Array("Picture 1")).Select
    Selection.ShapeRange.ScaleWidth 0.3434730056, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.375516335, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.9974999475, msoFalse, msoScaleFromTopLeft
 
With Application.FileDialog(msoFileDialogSaveAs)
  .Title = "Choose name of file"
  .InitialFileName = "C:\Users\***\Desktop\"  
  .AllowMultiSelect = False
  If .Show = -1 Then
      .Execute
  Else
     MsgBox "User pressed cancel!"
  End If
End With
 
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,590
Messages
6,179,749
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top