In this article, we will exhibit you 2 ways to quickly get the alternative texts of pictures, shapes, Tables, charts, SmartArt graphics, or other objects in Word document.
Sometimes, objects like shapes, pictures inserted into your document contain alternative texts. They help to explain the details of an object. However, these texts do not show themselves directly. Instead, you have to right click on an object. And choose “Format Object” to open “Format Shape” box. Next click “Alt Text” in order to see such information as “Title” and “Description”.
This is cumbersome and not intuitionistic enough. Therefore, we’d like to offer you 2 quicker methods to see or insert the alternative texts of objects in document.
Method 1: See the Alternative Texts of all Objects
For your reference, we tend to do it in macro way.
- First if all, press “Alt+ F11” in Word to trigger VBA editor.
- Next create a new module in “Normal” project. To do so, click “Normal”.
- Then click “Insert” tab and choose “Module” on its drop-down menu.
- Double click on the new module to open the editing space on the right side.
- Paste the following codes there:
Sub ShowAltText() Dim objDoc As Document Dim objShape As Object Set objDoc = ActiveDocument With objDoc For Each objShape In .Shapes If objShape.AlternativeText <> "" Then MsgBox ("Title: " & objShape.Title & vbNewLine & "Description:" & vbNewLine & objShape.AlternativeText) Else MsgBox ("There is no Alt Text.") End If Next For Each objShape In .InlineShapes If objShape.AlternativeText <> "" Then MsgBox ("Title: " & objShape.Title & vbNewLine & "Description:" & vbNewLine & objShape.AlternativeText) Else MsgBox ("There is no Alt Text.") End If Next For Each objShape In .Tables If objShape.Descr <> "" Then MsgBox ("Title: " & objShape.Title & vbNewLine & "Description:" & vbNewLine & objShape.Descr) Else MsgBox ("There is no Alt Text.") End If Next End With End Sub
- Last but not the least, click “Run” button.
You shall see message box popping up one after another. You will get the alternative text of each object in your document.
Here is an example:
Method 2: Insert the Alternative Text into Document
Now there is another case that is to extract and insert the alternative text of an object into document via VBA. This way, the alternative texts work very much like the “Caption” for figures and tables.
Here is how we do it:
- Firstly, follow the exact steps in method 1 to install and run a macro.
- Secondly, paste this macro:
Sub ShowAltTextBelowPic() Dim objDoc As Document Dim objShape As Object Set objDoc = ActiveDocument With objDoc For Each objShape In .Shapes objShape.ConvertToInlineShape Next For Each objShape In .InlineShapes objShape.Range.InsertAfter vbNewLine & objShape.Title & vbNewLine & objShape.AlternativeText Next For Each objShape In .Tables objShape.Select Selection.Collapse wdCollapseEnd Selection.InsertAfter vbNewLine & objShape.Title & vbNewLine & objShape.Descr Next End With End Sub
Check the result:
Handle Instances of Corrupted Documents
Have you ever run across a damaged docx? If true, you probably understand the feeling of scratching hair and hopping for solutions to visit the inaccessible documents again. Now to save you from such heart-broken situation, we recommend you taking a proficient repairing tool to retrieve lost data.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair Excel and pdf repair software products. For more information visit www.datanumen.com