Hi and thanks for reading my question!
I use .CopyFace/.PasteFace in one of my codes and they take advantage of Clipboard, which is a problem for me, because the clipboard may contain data (usualy text). I think I can either choose another method to replace Copy/PasteFace or store the clipboard content safely first. basically I think I need to figure out how to work with Clipboard, but I find the help in Office XP difficult to uderstand for me and the web contains mostly advice for newer VB. Could somebody kindly point me in the right direction? Below is the Office Help text I suspect holds the answer but I just cannot get it to run. Every time I try to use "Dim MyData as DataObject", it I get "Compile error: User-defined type not defined". I am doing something wrong but I dont know what.
Any help, please?
Best regards,
Pavel
---- help from office xp ----
Copy, GetFromClipboard, GetText Methods, DataObject Object Example
The following example demonstrates data movement from a TextBox to the Clipboard, from the Clipboard to a DataObject, and from a DataObject into another TextBox. The GetFromClipboard method transfers the data from the Clipboard to a DataObject. The Copy and GetText methods are also used.
To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:
Two TextBox controls named TextBox1 and TextBox2.
A CommandButton named CommandButton1.
Dim MyData as DataObject
Private Sub CommandButton1_Click()
'Need to select text before copying it to Clipboard
TextBox1.SelStart = 0
TextBox1.SelLength = TextBox1.TextLength
TextBox1.Copy
MyData.GetFromClipboard
TextBox2.Text = MyData.GetText(1)
End Sub
Private Sub UserForm_Initialize()
Set MyData = New DataObject
TextBox1.Text = "Move this data to the " _
& "Clipboard, to a DataObject, then to "
& "TextBox2!"
End Sub
I use .CopyFace/.PasteFace in one of my codes and they take advantage of Clipboard, which is a problem for me, because the clipboard may contain data (usualy text). I think I can either choose another method to replace Copy/PasteFace or store the clipboard content safely first. basically I think I need to figure out how to work with Clipboard, but I find the help in Office XP difficult to uderstand for me and the web contains mostly advice for newer VB. Could somebody kindly point me in the right direction? Below is the Office Help text I suspect holds the answer but I just cannot get it to run. Every time I try to use "Dim MyData as DataObject", it I get "Compile error: User-defined type not defined". I am doing something wrong but I dont know what.
Any help, please?
Best regards,
Pavel
---- help from office xp ----
Copy, GetFromClipboard, GetText Methods, DataObject Object Example
The following example demonstrates data movement from a TextBox to the Clipboard, from the Clipboard to a DataObject, and from a DataObject into another TextBox. The GetFromClipboard method transfers the data from the Clipboard to a DataObject. The Copy and GetText methods are also used.
To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:
Two TextBox controls named TextBox1 and TextBox2.
A CommandButton named CommandButton1.
Dim MyData as DataObject
Private Sub CommandButton1_Click()
'Need to select text before copying it to Clipboard
TextBox1.SelStart = 0
TextBox1.SelLength = TextBox1.TextLength
TextBox1.Copy
MyData.GetFromClipboard
TextBox2.Text = MyData.GetText(1)
End Sub
Private Sub UserForm_Initialize()
Set MyData = New DataObject
TextBox1.Text = "Move this data to the " _
& "Clipboard, to a DataObject, then to "
& "TextBox2!"
End Sub