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...
May 25, 2023
Hi,
> I.e., I have the right field selected in its entirety.
Not necessarily, as the Text property would always return the complete text in the text box regardless of the actual selection as long as it is the active control in the subform.
I would try to first explicitely set the focus to a different control in the subform and then explicitely to the desired control. With standard cursor behaviour set in the options, this should ensure that the complete text in the control is selected for the copy action.
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
demaionewton
May 25, 2023Copper Contributor
We are thinking alike. Here's what I tried to be sure it was all selected. The following code focuses on the subform field, selects the Start & Length, puts the Text in a string and shows it in a message box. The copy in the message box is correct. BUT, the next line DoCmd.RunCommand acCmdCopy does NOT copy to the clipboard.
Me![Case Attachments subform].Form![Doc Description].SetFocus
Me![Case Attachments subform].Form![Doc Description].SelStart = 0
Me![Case Attachments subform].Form![Doc Description].SelLength = Len(Me![Case Attachments subform].Form![Doc Description].Text)
Dim tryit As String
tryit = Me![Case Attachments subform].Form![Doc Description].Text
MsgBox (tryit)
DoCmd.RunCommand acCmdCopy
Me![Case Attachments subform].Form![Doc Description].SetFocus
Me![Case Attachments subform].Form![Doc Description].SelStart = 0
Me![Case Attachments subform].Form![Doc Description].SelLength = Len(Me![Case Attachments subform].Form![Doc Description].Text)
Dim tryit As String
tryit = Me![Case Attachments subform].Form![Doc Description].Text
MsgBox (tryit)
DoCmd.RunCommand acCmdCopy