E
EllenM
Hello,
I am trying to restrict users that use my form to assigning only text data
to a string variable when the source of this data is from the clipboard. As
you know, the Windows clipboard can hold image data as well. SEE CODE BELOW
including my comment on line 7.
Private Sub Paste_Click()
Dim MyData As DataObject
Dim Num as integer
Dim myStr As String
Set MyData = New DataObject
MyData.GetFromClipboard
myStr = MyData.GetText ‘’’ ON THIS LINE YOU CAN SEE WHERE PROBLEM MIGHT
PRESENT THEMSELVES
Sub
Unfortunately, I am not aware of any controls to prevent the user from
storing something other than text to the clipboard and then later trying to
assign that data to a string variable. As such, I am susceptible to receiving
the following message during runtime.
Run-time error '-2147221504 (80040064)':
DataObject:GetText Invalid FORMATETC structure
In the above example I tested to see if I would get an error message if I
copied image data to the clipboard and assign it to a text variable. And sure
enough, I did.
If there a way to filter out this error message?
Thanks,
I am trying to restrict users that use my form to assigning only text data
to a string variable when the source of this data is from the clipboard. As
you know, the Windows clipboard can hold image data as well. SEE CODE BELOW
including my comment on line 7.
Private Sub Paste_Click()
Dim MyData As DataObject
Dim Num as integer
Dim myStr As String
Set MyData = New DataObject
MyData.GetFromClipboard
myStr = MyData.GetText ‘’’ ON THIS LINE YOU CAN SEE WHERE PROBLEM MIGHT
PRESENT THEMSELVES
Sub
Unfortunately, I am not aware of any controls to prevent the user from
storing something other than text to the clipboard and then later trying to
assign that data to a string variable. As such, I am susceptible to receiving
the following message during runtime.
Run-time error '-2147221504 (80040064)':
DataObject:GetText Invalid FORMATETC structure
In the above example I tested to see if I would get an error message if I
copied image data to the clipboard and assign it to a text variable. And sure
enough, I did.
If there a way to filter out this error message?
Thanks,