View Single Post
 
Old 05-02-2023, 06:01 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

.AlternativeText still works but perhaps your logic in working out which graphic to apply it to is flawed.

ActiveDocument.InlineShapes(ActiveDocument.InlineS hapes.Count).Select
will select the LAST graphic in the file, which may or may not be the graphic you just inserted - depending on where you put your cursor.

Instead, you can harvest the path to the picture via the dialog without inserting it, and then insert the picture while defining it. You then have the right shape to assign the text to.
Code:
Sub TagMyNewPicture()
  Dim sPath As String, aInShape As InlineShape
  With Dialogs(wdDialogInsertPicture)
    .Display
    sPath = .Name
    Debug.Print sPath
  End With
  Set aInShape = Selection.InlineShapes.AddPicture(FileName:=sPath, LinkToFile:=False, SaveWithDocument:=True)
  With aInShape
    .AlternativeText = sPath
    .Title = "Look Mum, no hands"
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote