Strange “Argument not optional” error in VBA
-
06-07-2019 - |
Question
Private Sub importClipboard_Click()
Dim data As Collection
data = getClipboardData()
...do something...
End Sub
Function getClipboardData() As Collection
...do something...
End Function
I am getting an "Argument not optional" compile error on the line:
data = getClipboardData()
What am I doing wrong? There no arguments to the getClipboardData() function - so how can I be missing one?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow