返回列表 上一主題 發帖

[發問] VBA清除圖片問題

[發問] VBA清除圖片問題

從資料庫叫出一張照片貼到Sheet裡面,開始列印報告。

'插入圖片

    Application.ScreenUpdating = False

    Sheets("檢驗數據").Select
   
    ABC = Sheets("檢驗數據").Range("u13")
   
    Sheets("尺寸檢驗").Select
   
    ActiveSheet.Unprotect
   
    Range("B7").Select

    ActiveSheet.Pictures.Insert(ABC). _
        Select
   
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 190
    Selection.ShapeRange.Width = 205#
    Selection.ShapeRange.Rotation = 0#
   
    Selection.ShapeRange.ScaleWidth 1.35, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 1.35, msoFalse, msoScaleFromTopLeft
   
    Range("A1").Select
   
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
        
    Sheets("檢驗數據").Select
   
    Range("A1").Select

End Sub

但是,列印完了要把照片刪除 竟然刪不掉是我的語法有問題嗎?
在EXCEL 2003時還正常運作,這兩天換了EXCEL 2010 就清不掉圖片了,害我得手動進入到那Sheet去解開保護工作表來刪除照片。

   
'清除圖面
   
    Sheets("尺寸檢驗").Select
   
    ActiveSheet.Unprotect
   
    For Each I In ActiveSheet.Shapes
    If I.Type = msoPicture Then I.Delete
    Next
   
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
   
    Else
   
    End If

        靜思自在 : 修行要繫緣修心,藉事練心,隨處養心。
返回列表 上一主題