香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 19th Jul 2008, 11:50 AM | Excel 2007 | (956 Reads)

"InsertPic" Excel 2007問題

2003運行完全沒問題的 , 但2007就運行不能了

Question

用這方法試試吧

Sub InsertPictures()
    InsertPicture "C:\playstation.jpg", Range("C2"), 0.5
End Sub

Sub InsertPicture(ByVal PicturePath As String, _
                  ByVal TargetRange As Range, _
                  ByVal Scaling As Double)
    Dim NewImage As ShapeRange
    If Len(Dir(PicturePath)) > 0 Then
        Set NewImage = TargetRange.Parent.Pictures.Insert(PicturePath).ShapeRange
        NewImage.Left = TargetRange.Left
        NewImage.Top = TargetRange.Top
        NewImage.ScaleWidth Scaling, msoFalse, msoScaleFromTopLeft
        NewImage.ScaleHeight Scaling, msoFalse, msoScaleFromTopLeft
    End If
End Sub