For storing multiple data in Clipboard, Follow the below steps.

 

Steps:

  • Initialize the Data Object, the type of MSForms.DataObject
  • Initialize a String and an Integer.
  • Set the String into Data Object using SetText() method and provide format identifier
  • Put the data in ClipBoard using PutInClipboard
  • Fetch the data from ClipBoard using GetFromClipboard("format identifier")

Source code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Function FnStoreMultipleDataInClipBoard()
 
Dim objData As New MSForms.DataObject
Dim strText As String
Dim intData As Integer
 
	'---
	Set objData = New MSForms.DataObject
	
	'---
	strText = "I am the First One"
	intData = 5
	
	'---
	objData.SetText strText, "StringOne"
	objData.PutInClipboard
 
	'---
	objData.SetText intData, "IntegerOne"
	objData.PutInClipboard
 
	'---	
	MsgBox "Data in ClipBoard : '" & objData.GetText("StringOne") & _
		   "' And '" & objData.GetText("IntegerOne") & "'"
 
End Function 

 

Note: For working with Windows Clipboard you need DataObject, the object in MSForms library. It provides support for text-string.

For that you must add the reference Microsoft Forms 2.0 Object Library