Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you select an image that was just pasted to MS Word via VBA

Tags:

ms-word

vba

Just pasted an image to MS Word in VBA using the following

wordApp.Selection.PasteSpecial DataType:=wdPasteMetafilePicture, Placement:=wdInLine

My thinking is to move one char left and then select next object, but I don't know how to do this.

EDIT:

Well here are some encoraging development, using the following line, I was able to select the paragraph which include the image, but I can't manipulate it because it's selecting a range. Do anyone know how I can pin down the image inside the selection?

wordApp.Selection.Expand wdParagraph
like image 559
Bill Software Engineer Avatar asked Nov 05 '22 13:11

Bill Software Engineer


2 Answers

Here is what I used:

wordApp.Selection.Find.Execute replace:=2
wordApp.Selection.Expand wdParagraph
wordApp.Selection.InlineShapes(1).Select
like image 144
Bill Software Engineer Avatar answered Nov 15 '22 07:11

Bill Software Engineer


I was also doing the same. It seems that after pasting an image into word, its already selected. You can just use the selected object with the simple code below:

Selection.InlineShapes(1).Select
like image 38
user2521470 Avatar answered Nov 15 '22 05:11

user2521470