Search notes:

VBA: Microsoft Forms 2.0 Object Library

Adding a reference to the Forms library

In order to use the Forms library in a VBA project, a reference to the Microsoft Forms 2.0 Object Library must be added, for example by entering one of the following lines in the immediate window:
application.vbe.activeVBProject.references.addFromFile "C:\Windows\System32\FM20.dll"
application.vbe.activeVBProject.references.addFromFile "C:\Windows\SysWOW64\FM20.dll"

application.vbe.activeVBProject.references.addFromGuid "{0D452EE1-E08F-101A-852E-02608C4D0BB4}", 2, 0
Note, that this DLL does neither exist under C:\Windows\System32 or C:\Window\SysWOW64, but it is found under C:\Windows\dirs\Program Files (x86)\Microsoft Office\root\vfs\SystemX86\FM20.dll
It is not necessary to manually add the reference if a UserForm is added to a project in the VB Editor. In that case, the Editor will automatically add the required reference.
After adding the reference, constants such as fmBorderStyleSingle or fmBackStyleTransparent become available.

Accessing the clipboard

option explicit

'
'  Needs the "Microsoft Forms 2.0 Object Library" reference.
'  If this reference does not show up, it can be
'  added through the file
'    C:\Windows\System32\FM20.dll  or
'    C:\WINDOWS\SysWOW64\FM20.DLL  respectively
'

sub main()

  dim dObj as new dataObject
  dim txt as string

  txt = "This was copied to the clipboard using VBA!"

  dObj.setText "This text comes from a VBA function!"
  dObj.putInClipboard
  
  msgBox "Text was put in clipboard." & vbCrLf & "Check and put something into the clipboard yourself."
  dObj.getFromClipboard
  
  msgBox "Text currently in clipboard is:" & vbCrLf & dObj.getText

end sub
Github repository about-VBA, path: /object-libraries/microsoft-forms/clipboard.bas
Compare with Putting text into the clipboard with VBA and the WinAPI.

Classes (objects)

CheckBox
ComboBox A ComboBox combines a ListBox and a TextBox: new text can be entered and existing values can be chosen
CommandButton See also this example
Control
Controls
DataObject
Frame
HTMLCheckbox
HTMLHidden
HTMLImage
HTMLOption
HTMLPassword
HTMLReset
HTMLSelect
HTMLSubmit
HTMLText
HTMLTextArea
Image
Label
ListBox Displays a list of values from which a user can choose from. Compare with ComboBox.
MultiPage
NewFont
OptionButton
Page
Pages
PIROWSET
ReturnBoolean
ReturnEffect
ReturnInterger
ReturnSingle
ReturnString
ScrollBar
SpinButton
Tab
Tabs
TabStrip
TextBox Compare with ComboBox. See also this example.
ToggleButton
UserForm See also VBA's global intrinsic variable UserForms.

See also

Useful object libraries
The Excel object OLEObject.
Visual Basic for Applications

Index