A
Alan Rohulich
I am using VB.NET to modify a word doc, but am unable to select an existing
picture and replace it with an updated picture. Any help would be greatly
appreciated. To date I can select the picture using the following, but how
do I replace the picture with a new one from my C drive? I have tried
adding a shape, but it ignores the selection and puts the picture at the top
of the document. Thanks in advance.
Regards,
Alan
Sample Code:
oWordapp.Documents.Open("C:\Temp\Report.doc") ' Opens Doc
oWDoc = oWordapp.ActiveDocument() 'Activates
Doc
oWDoc.Content.Find.Execute(FindText:="^g") 'Finds Picture
1st occurrence
oWDoc.Shapes.AddPicture("C:\Temp\Area.jpg") 'Attempts to
replace Picture, but just Adds at top of Doc
picture and replace it with an updated picture. Any help would be greatly
appreciated. To date I can select the picture using the following, but how
do I replace the picture with a new one from my C drive? I have tried
adding a shape, but it ignores the selection and puts the picture at the top
of the document. Thanks in advance.
Regards,
Alan
Sample Code:
oWordapp.Documents.Open("C:\Temp\Report.doc") ' Opens Doc
oWDoc = oWordapp.ActiveDocument() 'Activates
Doc
oWDoc.Content.Find.Execute(FindText:="^g") 'Finds Picture
1st occurrence
oWDoc.Shapes.AddPicture("C:\Temp\Area.jpg") 'Attempts to
replace Picture, but just Adds at top of Doc