If you want to centralise the image it needs to be an inline shape. You can convert it, if you must, after you have centred it.
The argument lists for built in dialog boxes can be found at
https://msdn.microsoft.com/en-us/lib...or=-2147217396 from which you will see it is not possible to set the start location for this dialog. You would need to use a different dialog to set the location such as Application.FileDialog(msoFileDialogFilePicker) e.g.
Code:
Sub InsertPic()
Dim fDialog As FileDialog
Dim strFile As String
Dim oImage As InlineShape
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.Title = "Select image to insert"
.InitialFileName = "C:\Users\atom\Desktop\PDF\"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Images", "*.jpg,*.png,*.gif"
.InitialView = msoFileDialogViewList
If .Show <> -1 Then GoTo err_Handler:
End With
strFile = fDialog.SelectedItems.Item(1)
Set oImage = Selection.InlineShapes.AddPicture(strFile)
With oImage
.LockAspectRatio = msoTrue
.ScaleHeight = 50
.ScaleWidth = 50
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
.ConvertToShape
End With
lbl_exit:
Set fDialog = Nothing
Set oImage = Nothing
Application.WindowState = wdWindowStateNormal
' Documents.Add DocumentType:=wdNewBlankDocument
' ShowVisualBasicEditor = True
Exit Sub
err_Handler:
Err.Clear
GoTo lbl_exit
End Sub
Inserting multiple images and then converting them to shapes is a minefield. The shapes are not part of the document text (unlike inline shapes) and thus you would have to position them or they will tend to do their own thing.
It would be better if you inserted the images into the cells of a table (with fixed width cells) and left them as inline images. That would fixe their positions on the page and also negate the need to adjust the size, which would adapt to the cell width.
See
http://www.gmayor.com/photo_gallery_template.html