vba 如何从 getClipboardData 返回数据?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1032819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 09:51:48  来源:igfitidea点击:

How to return data from getClipboardData?

vbacompiler-errors

提问by jwoolard

Private Sub importClipboard_Click()
    Dim data As Collection
    data = getClipboardData()
    ...do something...
End Sub

Function getClipboardData() As Collection
    ...do something...    
End Function

I get

我得到

Compile error: Argument not optional"

编译错误:参数不是可选的”

on the line:

在线上:

data = getClipboardData()

There no arguments to the getClipboardData()function - so how can I be missing one?

getClipboardData()函数没有参数- 那么我怎么会错过一个呢?

回答by Joel Goodwin

It's a bad error message, but your problem is a common one - you've got to put Set data = getClipboardData()as you're returning an object.

这是一个糟糕的错误消息,但您的问题很常见 - 您必须Set data = getClipboardData()在返回对象时放置。