Excel的VBA粘贴剪贴板中的第二项(Excel VBA paste the second ite

2019-10-20 23:04发布

什么我想的是,我想多个项目时,我按ctrl + Q不是第一个加入到剪贴板,然后粘贴的第二个项目。 这里是我的代码,但我得到的第一个。

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+q
'


Dim DataObj As New MSForms.DataObject
Dim S As String


On Error GoTo NotText
DataObj.GetFromClipboard
S = DataObj.GetText 'take the first one into S
T = DataObj.GetText 'take the second one into T

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
NotText:
'don't want anything to happen.

ActiveCell.Value = T  'paste the second one(doesn't work)

End Sub
文章来源: Excel VBA paste the second item from clipboard