VBA Excel 2010 - Paste directly from clipboard

前端 未结 1 659
说谎
说谎 2021-01-07 08:04

I am trying to paste directly from the clipboard into an excel document and have it so it is transposed

Dim DataObj As MSForms.DataObject
 Set DataObj = New          


        
相关标签:
1条回答
  • 2021-01-07 08:44

    I think you need to specify target where to paste and on it call PasteSpecial method. You cant call pasteSpecial method of string as you trying. (because of that error with object required)

    Take a look at this

    Sub testPaste()
    
        Dim DataObj As MSForms.DataObject
        Set DataObj = New MSForms.DataObject
        DataObj.GetFromClipboard
    
        strPaste = DataObj.GetText(1)
    
        Sheets("Sheet2").Rows(1).PasteSpecial Transpose:=True
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题