jimmyk
08-28-2016, 05:30 AM
Hello,
I have a table with multiple rows. I am using the following code to select the cell in the next to the last row. With that cell selected, the following code works great to insert the image in that cell. The problem is that it inserts the caption UNDER the table and I would like to insert it in the cell under the image (the last row). Screenshot is attached.
Sub insertPicture()
Dim Doc As Dialog
Dim BClicked As String
Dim picPath As String
Dim picName As String
Set Doc = Dialogs(wdDialogInsertPicture)
With Doc
.Name = "*.jpg"
BClicked = .Show 'using show executes the dialog
picPath = .Name
End With
'strip off the path to get the file name
picName = Right(picPath, Len(picPath) - InStrRev(picPath, "\"))
'only do this if OK was clicked
If BClicked = -1 Then
Selection.InsertCaption Label:="Figure", _
TitleAutoText:="", Title:=": " & picName, _
Position:=wdCaptionPositionBelow
End If
End Sub
I have a table with multiple rows. I am using the following code to select the cell in the next to the last row. With that cell selected, the following code works great to insert the image in that cell. The problem is that it inserts the caption UNDER the table and I would like to insert it in the cell under the image (the last row). Screenshot is attached.
Sub insertPicture()
Dim Doc As Dialog
Dim BClicked As String
Dim picPath As String
Dim picName As String
Set Doc = Dialogs(wdDialogInsertPicture)
With Doc
.Name = "*.jpg"
BClicked = .Show 'using show executes the dialog
picPath = .Name
End With
'strip off the path to get the file name
picName = Right(picPath, Len(picPath) - InStrRev(picPath, "\"))
'only do this if OK was clicked
If BClicked = -1 Then
Selection.InsertCaption Label:="Figure", _
TitleAutoText:="", Title:=": " & picName, _
Position:=wdCaptionPositionBelow
End If
End Sub