Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-02-2023, 11:31 AM
MartinGM MartinGM is offline Change code now that Alt Text has changed Windows 11 Change code now that Alt Text has changed Office 2021
Competent Performer
Change code now that Alt Text has changed
 
Join Date: May 2023
Location: England
Posts: 108
MartinGM is on a distinguished road
Default Change code now that Alt Text has changed

I have just migrated to Office 365 and Alt Text functionality has changed, so I need to change a simple line of VBA . . . but I cannot see how to do this.

I used to insert an image using the Insert Picture dialog triggered by VBA, and capture the filename which automatically came across as Alt Text, as follows . . .



1. Set the dialog to the required image folder, display the list of images, then select the correct one manually . . .

Dim PicturePath As String
Dim FileName as String

'Save user's default image insertion path
PicturePath = Options.DefaultFilePath(Path:=wdPicturesPath)

'Change path to directory of the pictures
Options.DefaultFilePath(Path:=wdPicturesPath) = "C:\Users\Public\Pictures\ . . . ."

'Display the dialog
With Dialogs(wdDialogInsertPicture)
If .Show = False Then Exit Sub
End With

'Before quitting, restore the original pictures' path
Options.DefaultFilePath(Path:=wdPicturesPath) = PicturePath

ActiveDocument.InlineShapes(ActiveDocument.InlineS hapes.Count).Select

2. So now the correct image is inserted and selected.

3. Now for the one line of code that no longer works . . .

FileName = Selection.InlineShapes(1).AlternativeText 'Extract the Alternative Text

Unfortunately (for me) Microsoft has changed the AlternativeText function entirely and this field no longer comes into the document automatically as it used to. My question is how can I capture the filename of the image which I have just chosen and inserted ?

FYI I used to go on to extract the final section of the filename (less the file extension) and use that as the image's title in the Word document I am editing. This saved me a great deal of time and avoided transcription errors.

Thanks in advance for any advice.

Martin
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change code now that Alt Text has changed AutoOpen code to change date code to date text Legal Learning Center Word VBA 6 02-22-2020 02:24 PM
Change code now that Alt Text has changed Default opening changed from 2010 to 2016 - How to change it back on Win10? stimu Excel 5 09-28-2017 11:45 AM
Change code now that Alt Text has changed VBA Code to search for field codes with certain text before the Field code and to change style welcometocandyland Word VBA 4 02-08-2017 06:53 PM
Change code now that Alt Text has changed Code that will run when a cells value is changed. DonJohns1 Excel Programming 2 04-15-2015 10:48 AM
Need to delete 'field code changed' in my reference list leb Word 4 05-04-2013 12:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft