vwdevotee
10-27-2011, 01:10 PM
Hi. I'm new to VBA, but was hoping someone could help me out. I found this old macro here:
Sub InsertPicture2()
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
but it only puts one caption at the bottom of a long slew of pictures rather than the filename caption under each picture. Can anyone point me towards a version of this that puts individual captions in or could anyone please show my what's wrong with this? (that way I can start figure out how to do things automagically on my own) Thanks in advance.
Damon
Sub InsertPicture2()
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
but it only puts one caption at the bottom of a long slew of pictures rather than the filename caption under each picture. Can anyone point me towards a version of this that puts individual captions in or could anyone please show my what's wrong with this? (that way I can start figure out how to do things automagically on my own) Thanks in advance.
Damon