View Single Post
 
Old 10-27-2022, 05:59 PM
BrianHoard BrianHoard is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Hi,
I'm very new to VBA, but hopefully this can help.
In my code below, rather than using the clipboard, I'm storing your selection as formatted text. Writing that to the end of the document, then deleting the original selection. After the write to the end of the doc, I add a carriage return, (vbCr).

I also added a message in case nothing was selected.
I tested this with an image in the selection and it also worked fine.


Code:
Sub MoveToOutTakes()
  
  Dim docEnd As Range
  Set docEnd = ActiveDocument.Range
  docEnd.Collapse direction:=collapseEnd
  
  Dim sel As Range
  Set sel = Selection.FormattedText
  
  If (sel.Start = sel.End) Then
    Call MsgBox(Prompt:="Nothing selected.", Buttons:=vbInformation)
  End If
  
  docEnd.FormattedText = sel
  docEnd.InsertAfter (vbCr)
  sel.Delete

End Sub
Reply With Quote