Forum Discussion
demaionewton
May 24, 2023Copper Contributor
VBA: DoCmd.RunCommand acCmdCopy not working
I have a Rich Text Formatted Access field on a subform that I need to copy to the clipboard. Because Writeline doesn't have a FormattedText option, I can't simply write the field to the clipboar...
Giorgio Rovelli
May 24, 2023Copper Contributor
What does WriteIn do?
- demaionewtonMay 25, 2023Copper Contributor
Sorry, my bad. I meant writeline, not Writeln. Writeline writes the text following it to the clipboard. Here's an example:
Private Sub bCopyHelloWorldtoClipboard_Click()
Dim WshShell, oExec, oIn
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine "Hello World"
oIn.Close
End Sub- demaionewtonFeb 21, 2024Copper Contributor
The problem with Writeln is that it writes the rich text field with all of the html code exposed. Only DoCmd.RunCommand acCmdCopy will copy rich text to the clipboard. demaionewton