Word VBA, images
I need to complete a macro that inserts images from a folder and put under each one its file name, then resize them, then select them and put a black border to each image and its name, I have the following macro but I can't get you to select them to give them the border
---------------------------------------------------------------------------------------------------
Sub InsertSpecificNumberOfPictureForEachPage()
Dim xDlg As FileDialog
Dim xFilePath As String
Dim xFileName As String
Dim xMsbBoxRtn As Long
Dim xPicSize As String
Dim xShape As InlineShape
Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
If xDlg.Show = -1 Then
xFilePath = xDlg.SelectedItems(1) & ""
Else
Exit Sub
End If
xFileName = Dir(xFilePath & "*.*", vbNormal)
While xFileName <> ""
If Not (Right(xFileName, 4) = ".png" Or Right(xFileName, 4) = ".bmp" _
Or Right(xFileName, 4) = ".jpg" Or Right(xFileName, 4) = ".ico") Then
GoTo LblCtn
End If
With Selection
.InlineShapes.AddPicture xFilePath & xFileName, False, True
.TypeParagraph
.Collapse wdCollapsEnd
.TypeText Left(xFileName, InStrRev(xFileName, ".") - 1)
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.TypeParagraph
End With
LblCtn:
xFileName = Dir()
Wend
ActiveDocument.InlineShapes(1).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
xMsbBoxRtn = MsgBox("desea redimensionar las imagenes?", vbYesNo, "Kutools for Word")
If xMsbBoxRtn = 6 Then
xPicSize = InputBox("inserte el alto y ancho de las imagenes separado por coma", "Kutools for Word", "")
End If
For Each xShape In ActiveDocument.InlineShapes
xShape.Height = Split(xPicSize, ",")(0)
xShape.Width = Split(xPicSize, ",")(1)
Next xShape
End
Dim i As Long
With ActiveDocument
Dim img As InlineShape
For Each img In ActiveDocument.InlineShapes
img.Select
With img.Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorBlack
End With
With img.Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorBlack
End With
With img.Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorBlack
End With
With img.Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorBlack
End With
Next img
End
End With
End Sub
------------------------------------------------------------------------------------------------
If you could help me, I'd be very grateful
|