名为 Label1 的标签。
Dim MyDataObject As DataObject
Private Sub CommandButton1_Click()
'把标准格式放到剪贴板上
If TextBox1.TextLength > 0 Then
Set MyDataObject = New DataObject
MyDataObject.SetText TextBox1.Text
Label1.Caption = "Put on D.O."
CommandButton2.Enabled = True
CommandButton4.Enabled = False
End If
End Sub
Private Sub CommandButton2_Click()
'从剪切板得到标准格式
If MyDataObject.GetFormat(1) = True Then
Label1.Caption = "Std format - "_
& MyDataObject.GetText(1)
End If
End Sub
Private Sub CommandButton3_Click()
'把自定义格式放到剪切板上
If TextBox1.TextLength > 0 Then
Set MyDataObject = New DataObject
MyDataObject.SetText TextBox1.Text, 233
Label1.Caption = "Custom on D.O."
CommandButton4.Enabled = True
CommandButton2.Enabled = False
End If
End Sub
Private Sub CommandButton4_Click()
'从剪切板得到自定义格式
If MyDataObject.GetFormat(233) = True Then
Label1.Caption = "Cust format - "_
& MyDataObject.GetText(233)
End If
End Sub
Private Sub UserForm_Initialize()
CommandButton2.Enabled = False
CommandButton4.Enabled = False
End Sub