Word: How to replace images and rename them in VBA

mesp9942

New Member
Joined
May 20, 2013
Messages
5
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.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
The easiest way to process a set of images in Word is to place them in bookmarks, and loop through the collection of bookmarks.
This article isn't quite what you want but it shows how to loop through the bookmarks, in this case replacing them with pictures from Excel: Update a Word file by pulling Excel data into bookmarks -- DataWright Information Services

Denis

The problem is I need all of my images to be put into a bookmark in order to replace them with strings. The only strategy for selecting the images and placing them in bookmarks I have found is selecting them as inlineobjects or inlineshapes and then moving them to a bookmark. My problem is that inlineshapes does not consider all of my images that have been extracted by converting the document to html(webpage). I need all of my images to be put into a bookmark in order to process through them-how can I do this?? If I select them from a saved folder path, they will not be replaced in the location needed on my word doc...
-Meghan
 
Upvote 0
One approach would be to create the bookmarks manually -- see Add or delete bookmarks - Word - Office.com
Then create a 2-column table (you could use the Excel example) with bookmark names in the first, and the full path to your images in the second, and use that code to repopulate the bookmarks.

Denis

My problem is I would want to quickly assign a bookmark to each image with a macro all at once, or create a loop to assign each image to a bookmark. Manually would take too much time. I do not know how to identify all images in a doc to assign them to a bookmark, which is the issue here.
 
Upvote 0

Forum statistics

Threads
1,225,644
Messages
6,186,151
Members
453,339
Latest member
Stu61

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top