trevexcel2
New Member
- Joined
- Aug 21, 2008
- Messages
- 36
In Excel VBA, to manipulate the clipboard (buffer), one method is the following:
Include [Microsoft Forms 2.0 Object Library] from \ tools \ references.
Or simply add at least one userform in your project.
But it only works for Excel, not MS Word (Office 2007)!
Because the Microsoft Forms 2.0 Object Libary is not in the list in MS Word, in \tools \ references! Adding a userform doesn’t help also.
But the following code, which I got from a guy named Rory (I think on this forum, and years ago), indeed works!
Rory you're so great.
Include [Microsoft Forms 2.0 Object Library] from \ tools \ references.
Or simply add at least one userform in your project.
Code:
Dim myData As DataObject
Set myData = New DataObject
With myData
.SetText ActiveCell.Formula 'contents of cell is obtained
.PutInClipboard 'and put it into the clipboard.
End With
'Below = to get it out of the clipboard again, and store it in findStr.
With myData
.GetFromClipboard
findStr = .GetText
End With
Because the Microsoft Forms 2.0 Object Libary is not in the list in MS Word, in \tools \ references! Adding a userform doesn’t help also.
But the following code, which I got from a guy named Rory (I think on this forum, and years ago), indeed works!
Code:
[FONT=Arial]dim myData as object[/FONT]
[FONT=Arial]Const dataObjStr As String = "New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}"[/FONT]
[FONT=Arial]Set myData = GetObject(dataObjStr)[/FONT]
Rory you're so great.
---oOo---