![]() |
|
#4
|
||||
|
||||
|
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 |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Visio 2016 diagrams embeded in word 2016 not drawing properly
|
stubbo66 | Visio | 2 | 08-24-2016 05:58 PM |
Using a display alert command in Word
|
ch1325 | Word VBA | 2 | 04-30-2016 06:50 AM |
How to run command in word
|
si14 | Word | 3 | 06-10-2015 04:08 PM |
| From the command line, how do I run a Word macro? | jdockstader | Word | 7 | 02-04-2013 06:09 AM |
| Invoking a command line from inside Word | bolpom | Word | 1 | 03-16-2011 03:03 AM |