-1

I have an picture (jpg) stored in an image control in an embedded form in a word document. My goal is to copy this picture from the form to the word document by using a VBA macro. Unfortunately I have found no way of achieving this.

Has anyone done this in the past and is willing to share his solution?

Dirk
  • 1
  • See: https://stackoverflow.com/questions/39521019/copy-picture-from-userform-to-spreadsheet. Just change the line that inserts the pic into the worksheet so it inserts it into the document. You will, of course, need to tell Word *where* to insert the pic. – macropod Feb 17 '21 at 11:40
  • Thanks, but this solves my problem only partially - I'd like to avoid the temporary file for confidentiality issues. Sorry for not mentioning this restriction in my initial question. – Dirk Feb 17 '21 at 12:45

1 Answers1

0

Try something like this ...

Sub CopyPasteImages()
    Dim cc As Word.contentControl, rng As Word.Range
    For Each cc In ActiveDocument.ContentControls
        If cc.Range.InlineShapes.Count > 0 And cc.Type = wdContentControlPicture Then
            cc.Range.InlineShapes(1).Range.Copy
            Set rng = ActiveDocument.Bookmarks("\EndOfDoc").Range
            rng.Paste
        End If
    Next
End Sub
Rich Michaels
  • 1,663
  • 2
  • 12
  • 18