View Single Post
 
Old 07-04-2017, 09:06 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I have no idea why the code you have used previously no longer works for you (it doesn't work here), but adding file selector is easy enough
Code:
Dim oRng As Range
Dim oShp As InlineShape
Dim sName As String
Dim lngWidth As Long
Dim fDialog As FileDialog
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
    With fDialog
        .Title = "Select the image to insert"
        .InitialFileName = Environ("USERPROFILE") & Chr(92) & "Pictures"
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "Graphics Files", "*.jpg,*.png,*.gif, *.bmp, *.tif"
        .InitialView = msoFileDialogViewList
        If Not .Show = -1 Then Exit Sub
        sName = fDialog.SelectedItems.Item(1)
    End With
    Set oRng = Selection.InlineShapes(1).Range
    lngWidth = Selection.InlineShapes(1).Width
    oRng.Text = ""
    Set oShp = oRng.InlineShapes.AddPicture(sName)
    oShp.LockAspectRatio = msoTrue
    oShp.Width = lngWidth
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote