复制并存储到剪贴板

时间:2013-01-09 17:31:23

标签: excel excel-vba vba

我想使用AHK将我的文本从excel复制并存储到剪贴板。

这是我的代码:

Xl.Range("A1").Copy
Xl.Range("A2").Copy
Xl.Range("A3").Copy
Xl.Range("A4").Copy

如何将A1-A4存放到剪贴板?然后我可以手动粘贴剪贴板。

1 个答案:

答案 0 :(得分:1)

Dim wsSource As Worksheet, wsDest As Worksheet
Dim rngSource As Range, rngDest As Range
Set wsSource = ActiveSheet 'or whatever
Set wsDest = wsSource ' or whatever
Set rngSource = wsSource.Range("A1:A4")
Set rngDest = wsDest.Range("C1")
rngSource.Copy rngDest

除非您确实希望将其放在剪贴板上以供用户粘贴,否则您可以将弹性线更改为rngSource.Copy