![]() |
|
|
|
#1
|
|||
|
|||
|
SOLVED
OK, coming at this from a different direction, here is how I can insert a picture AND capture its filename. It is much simpler than the AltText method I used to use. In passing, I go on to use the filename with the extension stripped off, as the picture caption in my document. Sub InsertThumbnail() Dim objFSO As New FileSystemObject Dim FileName As String 'The filename of the inserted picture Dim FullPath As String 'The fliepath of the picture to be inserted Dim ThumbnailsFolder As String 'The folder containing the picture to be inserted 'Insert the picture, capturing the file name in the process ThumbnailsFolder = "C:\<My Location>" With Application.FileDialog(msoFileDialogOpen) 'Open the Thumbails folder .InitialFileName = ThumbnailsFolder 'Set where the dialog opens .Title = "Choose a file to insert" 'Title for the dialog box .AllowMultiSelect = False If .Show <> -1 Then Exit Sub FileName = objFSO.GetFileName(.SelectedItems(1)) 'Capture the filename FullPath = ThumbnailsFolder & FileName 'Set the full path of the picture, for later insertion End With Selection.InlineShapes.AddPicture FileName:=FullPath, LinkToFile:=False, _ SaveWithDocument:=True 'Insert the picture End Sub Last edited by MartinGM; 05-12-2023 at 09:41 AM. |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
AutoOpen code to change date code to date text
|
Legal Learning Center | Word VBA | 6 | 02-22-2020 02:24 PM |
Default opening changed from 2010 to 2016 - How to change it back on Win10?
|
stimu | Excel | 5 | 09-28-2017 11:45 AM |
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 |
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 |