none
Copy a picture from one sheet to another in excel using vb.net RRS feed

Answers

  • I managed to find a solution

    Dim pictMove As Excel.Range = Globals.ThisAddIn.Application.Sheets("Sheet2").Range("A1:A1")
    
    
            Try
                For Each shp In Globals.ThisAddIn.Application.ActiveSheet.Shapes
    
                    If (shp.Name = "Picture 1") Then
                        shp.copy()
    
                    End If
                Next
                pictMove.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll)
            Catch ex As Exception
    
            End Try

    • Marked as answer by jbrotto Monday, February 12, 2018 5:33 PM
    Monday, February 12, 2018 5:33 PM

All replies

  • Hello,

    VSTO doesn't provide any methods or properties for that. 

    If you want to know which methods and properties from the Excel object model should be used for that, you can use the Macro Recorder available in Excel. It allows to record your actions and to get a resulting VBA macro where you can see the sequence of property and method calls to get the job done. Hope it helps.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, February 12, 2018 8:18 AM
  • this is the code I get in vba but I don't know how to translate it into vb.net

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        ActiveSheet.Shapes.Range(Array("Picture 1")).Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        ActiveSheet.Paste
    End Sub
    

    Monday, February 12, 2018 3:54 PM
  • I managed to find a solution

    Dim pictMove As Excel.Range = Globals.ThisAddIn.Application.Sheets("Sheet2").Range("A1:A1")
    
    
            Try
                For Each shp In Globals.ThisAddIn.Application.ActiveSheet.Shapes
    
                    If (shp.Name = "Picture 1") Then
                        shp.copy()
    
                    End If
                Next
                pictMove.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll)
            Catch ex As Exception
    
            End Try

    • Marked as answer by jbrotto Monday, February 12, 2018 5:33 PM
    Monday, February 12, 2018 5:33 PM