Hello all, struggling government programmer again. I'm trying to make a button that will copy text to the clipboard so I can paste it into a PDF file for routing sheets. However the guides say I need Microsoft Forms 2.0 Object Library, which I do not have nor can I get installed on these computers. So I need an "alternative" way to do it.
I'm wondering if there's a way to have VBA select the contents of a form field (Which I'll set to the text string I want) and send the "Copy to clipboard" command.
Edit
SOLUTION: Used DoCmd.RunCommand acCmdCopy to copy the field with current focus, and a previous command to set the focus to the field with the text.
I tried the following, none of which worked
Code:
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText "A string value"
clipboard.PutInClipboard
Dim ObjRoutingSheet As New DataObject
Dim StrRoutingSheetText As String
StrRoutingSheetText = Me.Identification & " packet for " & Me.Event & " on " & Me.DateStart & " in " & Me.Location & "."
ObjRoutingSheet.SetText StrRoutingSheetText
ObjRoutingSheet.putinclipboard
Dim myClipboard As New vbaClipboard ' Create clipboard
' Copy text to clipboard as ClipboardFormat TEXT (CF_TEXT)
myClipboard.SetClipboardText "Text to put in clipboard", "CF_TEXT"