Add a bookmark for an embedded picture

BambooBart

New Member
Joined
Aug 23, 2023
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hi there,

When I select a picture in Word I am as a user able to add a bookmark to that picture. I have been looking for a way to do this using vba. The only examples I find start from a .bmp or picture file. I don't have the picture file, I just want to automate in vba what I can do as a user.
Any suggestions? I tried active document. bookmarks.add name:="test", range:=selection.range where the picture was selected but that gave an error
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I just realized that my question is about word and not excel. The reason that is posted it on this forum is that it is part of my effort to copy and paste an excel chart in a word document. I got that working but without loosing the bookmark I can't get rid of the text in the bookmark that remains there after I paste the picture from excel.
I can set the text in the bookmark to a single space but I want the user to have a meaning full and visible feedback about the bookmark
 
Upvote 0
Seems like some relevant code at the above link. HTH. Dave
 
Upvote 0
Seems like some relevant code at the above link. HTH. Dave
Thanks Dave,

Using .paste as shown in the code allowed me to set the bookmark again. However pasting a chart doesn't react well to resizing. When using .pastespecial the bookmark could not be set in that way. However, the code inspired me to try something else and that worked by using the inlineshapes().range

If .Bookmarks.Exists("chart_WV") Then

Set oRng = .Bookmarks("chart_WV").Range
Sheets("Sheet1").ChartObjects("chart_WV").Chart.ChartArea.Copy
oRng.PasteSpecial Link:=False, DataType:=9, Placement:=0, DisplayAsIcon:=False ' Werkt maar de bookmark is weg
NoShapes = NoShapes + 1
Set oRng = .inlineshapes(NoShapes).Range
oRng.Bookmarks.Add Name:="chart_WV", Range:=oRng
.inlineshapes(NoShapes).Height = 115.2 * 0.8
.inlineshapes(NoShapes).Width = 220.3 * 0.8


End If
 
Upvote 0
Solution

Forum statistics

Threads
1,215,149
Messages
6,123,311
Members
449,095
Latest member
Chestertim

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