Consulting

Results 1 to 7 of 7

Thread: Solved: Clear .Jpeg

  1. #1
    VBAX Regular
    Joined
    Oct 2010
    Location
    Texas
    Posts
    93
    Location

    Solved: Clear .Jpeg

    Hello Everyone,

    I need your help. I'm able to import a .jpeg picture into a spreadsheet. I can then copy it to another spreadsheet in the same workbook. I can do both using VBA code. The problem I'm having is using code to clear the picture on the user form. This is what I've tried so far:

    [VBA]Sub ClearInputs()
    With wksNewOrder
    .Range("i33:aa44").ClearContents
    End With
    End Sub[/VBA]


    I've also tried:

    [VBA]Sub NewOrderClearInputs()
    Application.ScreenUpdating = False
    Range("c8:c8").Select
    Selection.ClearContents
    End Sub[/VBA]

    I feel like there's a simple solution that I'm just not seeing. I don't think I'm calling out the pic correctly in the code.

    Any assistance you can provide will be greatly appreciated!

    Thank you!

  2. #2
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location

    Remove all pictures

    I am using this code, but remember it will remove all the pictures:

    [VBA]Sub Proc2()
    ' Remove pictures
    Dim DrObj
    Dim Pict
    Set DrObj = ActiveSheet.DrawingObjects
    For Each Pict In DrObj
    If Left(Pict.Name, 7) = "Picture" Then
    Pict.Select
    Pict.Delete
    End If
    Next
    End Sub
    [/VBA]

  3. #3
    VBAX Regular
    Joined
    Oct 2010
    Location
    Texas
    Posts
    93
    Location
    Works Great!!

    Thank you very much!!

  4. #4
    VBAX Regular
    Joined
    Oct 2010
    Location
    Texas
    Posts
    93
    Location
    Can the code be altered so that only pictures in a certain range on the worksheet are cleared?

    Thank you!!

  5. #5
    VBAX Regular
    Joined
    Oct 2010
    Location
    Texas
    Posts
    93
    Location

    Clear .jpeg in a range

    Quote Originally Posted by softman
    I am using this code, but remember it will remove all the pictures:

    [vba]Sub Proc2()
    ' Remove pictures
    Dim DrObj
    Dim Pict
    Set DrObj = ActiveSheet.DrawingObjects
    For Each Pict In DrObj
    If Left(Pict.Name, 7) = "Picture" Then
    Pict.Select
    Pict.Delete
    End If
    Next
    End Sub
    [/vba]
    Can the code be altered so that it clears a .jpeg only in a designated range on the worksheet?

    Thank you!!

  6. #6
    VBAX Regular
    Joined
    Mar 2010
    Posts
    49
    Location

    Removing picture in a range

    Hi Chem101,

    Here is the solution you are looking for removing pictures in a range:

    [VBA]Sub Proc2()
    Dim s As String
    Dim pic As Picture
    Dim rng As Range
    ' Set ws = ActiveSheet
    Set ws = ActiveWorkbook.Worksheets("Pixtures")
    Set rng = ws.Range("A6:O145")
    For Each pic In ws.Pictures
    With pic
    s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
    End With
    If Not Intersect(rng, ws.Range(s)) Is Nothing Then
    pic.Delete
    End If
    Next
    End Sub
    [/VBA]

  7. #7
    VBAX Regular
    Joined
    Oct 2010
    Location
    Texas
    Posts
    93
    Location
    Thank you very much for your response. The help I've received from you all is greatly appreciated!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •