PDA

View Full Version : word macro to rename and replace images



mesp9942
05-20-2013, 08:20 PM
Hi,
I have a word document with images in it and using microsoft word VBA I want to go through the document, name each image, and move these images to a folder.
I have tried inlineobjects, but this does not include each image on my page. The only way I have been able to extract them is by saving the doc as a webpage, but I am not able to delete or rename the images this way.
Please help.

fumei
05-20-2013, 09:44 PM
you may want to check out this thread.

http://www.vbaexpress.com/forum/showthread.php?t=46198

macropod
05-21-2013, 02:56 AM
Cross-posted at: http://www.mrexcel.com/forum/general-excel-discussion-other-questions/703948-word-how-replace-images-rename-them-visual-basic-applications.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

mesp9942
05-21-2013, 08:40 AM
Ok, so I have now renamed each image and placed them into a folder, which is great. My next step is to replace each image with the string "{{imagename}}". For example for image001.jpg I would want to replace it with "{{image001.jpg}}". The tricky part about this is that I need the extension to be correct. For example some of my images are .png and some are .jpg. I need to either convert all the images to .jpg or .png somehow, or be able to identify the extension in order to assign the correct string to replace each respective image. Please help!

fumei
05-25-2013, 11:13 PM
Hard to say as you have not bothered to post any code.

However, you will have huge problems if you do this in two steps (action the images and THEN try to replace the images with a string.

I would suggest actioning any given image and them immediately replace it with your string, assuming of course you know what the extension is. I would think that is a reasonable assumption as you have just saved the image file.