I have a need for a macro in excel that will take any number of pictures I paste into a worksheet, maximize their size for the printable page, and then put them all on different pages so when I print each picture will be allocated to one page. I'm trying it first with two shapes. I want each shape maximized for the page size, and put on two separate printable pages (in the same worksheet). The help files say to use the "Distribute" command, but I can't get it to work. I've tried it in Excel 2000 and 2003.

I know how to size the pictures, but can't get the Distribute command to work. With the attached code, I get a run time error and the message: "The specified value is out of range".

Here's the code right from the help files:


Code:
Sub Macro1()

Set mydocument = Worksheets(1)
With mydocument.Shapes
    numShapes = .Count
    If numShapes > 1 Then
        numAutoShapes = 0
        ReDim autoShpArray(1 To numShapes)
        For i = 1 To numShapes
            If .Item(i).Type = msoAutoShape Then
                numAutoShapes = numAutoShapes + 1
                autoShpArray(numAutoShapes) = .Item(i).Name
            End If
        Next
        If numAutoShapes > 1 Then
            ReDim Preserve autoShpArray(1 To numAutoShapes)
            Set asRange = .Range(autoShpArray)
            asRange.Distribute msoDistributeVertically, False
        End If
    End If
End With

End Sub