Hey guys, hope you guys can shed some light on some issue I've been facing.
I have this simple code here:
Sub ExcelForumTest()
Call Copy2Clipboard("Apples")
End Sub
Sub Copy2Clipboard(str As String)
Dim o As New DataObject
o.SetText str
o.PutInClipboard
End Sub
Sub ExtractFromClipboard()
Dim o As New DataObject
Dim str As String
o.GetFromClipboard
On Error Resume Next
str = o.GetText
On Error GoTo 0
Debug.Print Len(str) '<--- length of 2
Debug.Print Asc(Mid(str, 1, 1)) '<--- code 63
Debug.Print Asc(Mid(str, 2, 1)) '<--- code 63
Debug.Print str '<--- spits out in immediate window "??"
End Sub
This code has been working fine for me until fairly recently, but I don't know what's causing the issue.
The problem I've been having is that, whenever I push stuff into clipboard (i.e. run the macro ExcelForumTest) - when I paste it (CTRL V), it spits out 2 odd characters ASCII code 63 or square boxes in Excel, question marks when pasted in VBE, nothing in Notepad.
When I try to analyse via VBA using the "ExtractFromClipboard" macro, I am faced with the same issue.
My current system:
Windows 10 Pro
Intel Core i7
8.00 GB RAM
64-bit Operating System
Problem persists in all Excel 2007, 2010, and 2013 (32-bit).
I've repaired Excel once - which worked for maybe 5 minutes, then it reverted to the strange characters again.
Happy to hear any insights anyone here might have.
Bookmarks