VBA 를 사용 하여 EXCEL 에 그림 사용자 정의 함수 삽입(네트워크 URL/로 컬 URL)

1280 단어 VBA
Sub InsertPic(ByVal      As String, ByVal        As String, ByVal           As String)
    On Error Resume Next
    Dim rng As Range
    Set rng = Sheets(      ).Range(         )
    With Sheets(      ).Pictures.Insert(    )
        .ShapeRange.LockAspectRatio = msoFalse '      
        .Width = rng.Width - 3
        .Height = rng.Height - 3
        .Top = rng.Top + 1.5
        .Left = rng.Left + 1.5
        If Err.Number <> 0 Then
            .Delete
            Err.Clear
        End If
    End With
    Set rng = Nothing
End Sub
Sub InsertPic2(ByVal      As String, ByVal        As String, ByVal           As String)
    On Error Resume Next
    Dim rng As Range
    Set rng = Sheets(      ).Range(         )
    With Sheets(      ).Shapes.AddShape(msoShapeRectangle, rng.Left + 1.5, rng.Top + 1.5, rng.Width - 3, rng.Height - 3).Select '       
        Selection.ShapeRange.Fill.UserPicture      '       
        Selection.ShapeRange.Line.Visible = msoFalse '   
        If Err.Number <> 0 Then
            Selection.Delete
            Err.Clear
        End If
    End With
    Set rng = Nothing
End Sub
Sub   ()
    Call InsertPic("http://www.baidu.com/img/bd_logo1.png", ActiveSheet.Name, "c1")
End Sub

좋은 웹페이지 즐겨찾기