I want to replace an image inside a word file. I have a problem when entering an image, which is to displace all words with the text content and change the position of words.
What I do is bookmark the image and add the image.
-What I want is to replace the image with the word file without removing any content, and the image comes from datatable and not the image file
my code
Dim aplication As New Microsoft.Office.Interop.Word.Application Dim myapp1 As New Application Dim filename = "path file" Dim mydoc As New Document mydoc = aplication.Documents.Open(filename) Dim bk As Bookmarks = mydoc.Bookmarks bk("pic").Range().InlineShapes.AddPicture( FileName:="path file\Image.jpeg", LinkToFile:=False, SaveWithDocument:=True) mydoc.InlineShapes(1).Height = 100.5 mydoc.InlineShapes(1).Width = 100.14 GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() GC.WaitForPendingFinalizers()
https://stackoverflow.com/questions/66501388/replace-an-image-inside-a-word-file March 06, 2021 at 09:05AM
没有评论:
发表评论