How to return the descriptive (alternative) text string for a Shape object in excel?

Mayes, Meredith 0 Reputation points
2023-06-08T16:01:07.09+00:00

Looking for VBA code for Excel that will read the Alt Text for an image and paste the alt text string in a cell.

https://learn.microsoft.com/en-us/office/vba/api/excel.shape.alternativetext only showed an example for how to set Alt Text but not how to return the alt text in a cell.

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.9K Reputation points
    2023-06-09T17:45:35.38+00:00

    For example, to put the Alt Text of the first shape to F1:

    Range("F1").Value = Worksheets(1).Shapes(1).AlternativeText
    

    If the picture has some name:

    Range("F1").Value = Worksheets("Sheet1").Shapes("MyPicture1").AlternativeText
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.