Excel VBA形状粘贴不工作
我试图从sheet1粘贴文本框到sheet2
Function footer() Application.Volatile True r = Application.Caller.Address SheetName = Application.Caller.Parent.Name Select Case Range("Locale").Value Case "RU": boxx = Range("company").Value & Range("Locale") Case "EN": boxx = Range("company").Value & Range("Locale") End Select Worksheets("Translations").Shapes(boxx).Copy MsgBox Worksheets("Translations").Shapes(boxx).TextFrame.Characters.Text ActiveSheet.Paste End Function
Msgbox看起来不错,但粘贴function什么都不做,我尝试了不同的方式
- ActiveSheet.range( “A1”)。粘贴
- ActiveSheet.range( “A1”)。PasteSpecial的
- 工作表(SHEETNAME).Paste
- 工作表(SHEETNAME).Range(R).Paste
所有不工作,只是没有出现在表中,什么是错的?
尽pipe无法复制和粘贴形状,但您可以添加新的形状并从原始文本复制文本和格式 – 例如:
Function footer() Dim boxx As String Dim shpTo As Shape Dim shpFrom As Shape Application.Volatile True Select Case Range("Locale").Value Case "RU": boxx = Range("company").Value & Range("Locale") Case "EN": boxx = Range("company").Value & Range("Locale") End Select Set shpFrom = Worksheets("Translations").Shapes(boxx) With Application.Caller Set shpTo = .Worksheet.Shapes.AddShape(shpFrom.AutoShapeType, .Left, .Top, shpFrom.Width, shpFrom.Height) shpTo.TextFrame.Characters.Text = shpFrom.TextFrame.Characters.Text End With shpFrom.PickUp shpTo.Apply End Function
试试这个复制方法
ThisWorkbook.Sheets("Sheet1").Shapes.Range(Array(shpFrom.Name)).Select Selection.Copy