I have figured out how to replace words in documents as this is fairly easy using the find object. Now I am struggling with replacing the word “logo” with an actual logo image throughout a word document.
I figured I can loop through each Range in the document and say that if the word logo is found in the range, I can add a picture doing:
foreach (Range rngStory in doc.StoryRanges)
{
rngStory.InlineShapes.AddPicture(filename);
}
The problem is that this will add the picture to the top of the range and not exactly where the text logo is.
Does anyone have a good solution for doing this?
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshapes.addpicture%28v=office.11%29.aspx
See the optional Range parameter
So I would say you query for the current position where you have you logo tag, and use that as the Range value.