简体   繁体   中英

Finding Image reference in MS Word using VBA

I am trying to copy an excel Table and image from MS EXCEL to MS WORD using VBA. I was struggling to find out how will I reference the tables and images into the Word once they are sent from excel. After a long research I came across a very simple answer for table :

 Range("C1:D8").Copy Dim WDDoc As Word.Document Dim table1 As Word.Table Dim para As Paragraph Set para = WDDoc.Paragraphs.Add para.Range.PasteSpecial Link:=False, DataType:=wdPasteRTF, Placement:=wdInLine, DisplayAsIcon:=False 

set table1 = WDDoc.Tables(1) ' getting reference for the Pasted tables in word

table1.Shading.BackgroundPatternColor = wdColorBlueGray

What I have done:
I am able to copy an image from excel and simply pasting it on to word doc. para.

What I need?
after copying n picture i am not able to refer to that picture in word and hence not able to edit or resize the image once it is pasted.

Try this

With ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count)
    .Height = 314.95 ' or whatever
End With

This assumes that the picture is pasted "in line with text" (as you do) and is the last (furthest down) in-line picture in the document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM