Копировать фигуры из одного листа Excel в другой с помощью VBA - PullRequest
1 голос
/ 04 октября 2019

Я хочу иметь возможность копировать и вставлять фигуры из одного листа Excel в другой, не меняя его положение на этом листе. Следующий код позволяет мне копировать и вставлять фигуру из одного места в другое, но она меняет положение моей фигуры на

Set sh = WshSrc.Shapes("Rectangle 2")

    For Each WshTrg In ThisWorkbook.Worksheets
      If WshTrg.Name <> "Base" And WshTrg.Name <> "Format" Then
        WshTrg.Cells.PasteSpecial xlPasteFormats
        WshTrg.Cells.PasteSpecial xlPasteColumnWidths
        WshTrg.Cells.PasteSpecial xlPasteFormulasAndNumberFormats
        WshTrg.Cells.PasteSpecial xlPasteAll
        End If
    Next WshTrg
  Set WshSrc = Nothing

    For Each WshTrg In ThisWorkbook.Worksheets
      If WshTrg.Name <> "Base" And WshTrg.Name <> "Format" Then
        'sh.Name = WshSrc.Name & "_" & sh.Name
        sh.Copy
        WshTrg.Paste
        End If
        With sh
            .Height = PasteCell.Height
            .Width = PasteCell.Width
            .Top = PasteCell.Top
            .Left = PasteCell.Left
        End With
     Next WshTrg

1 Ответ

0 голосов
/ 04 октября 2019
sh.copy
WshTrg.Paste
Set sh2 = WhsTrg.Shapes(sh.name)
sh2.Left = sh.Left
sh2.Top = sh.Top
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...