View Single Post
 
Old 12-11-2023, 04:09 PM
nubuki nubuki is offline Windows 10 Office 2021
Novice
 
Join Date: Dec 2023
Posts: 3
nubuki is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
I think VBA will be relatively straightforward if the shape is always the same. I would be inclined use inline shapes though as it takes a lot of the complexity away.

If you post a sample document showing a couple of the graphics as you expect to see them then I can probably offer some code that would reproduce that from a folder of images.
Basically the rectangular shape should fill the page except the footer then the picture should fill the shape.
I'm using a shape instead of inserting directly because each photo size is dynamic.

I managed to write a vba that fill all shapes in a document with specified pictures:
Code:
Sub FillShapesWithPictures()
    Dim dialog As FileDialog
    Dim selectedFiles As FileDialogSelectedItems
    Dim i As Integer
    
    Set dialog = Application.FileDialog(msoFileDialogFilePicker)
    dialog.Title = "Select multiple JPG files"
    dialog.Filters.Add "JPEG files", "*.jpg; *.jpeg", 1
    
    If dialog.Show = -1 Then
        Set selectedFiles = dialog.SelectedItems
        
        i = 1
        For Each shape In ActiveDocument.Shapes
            If i <= selectedFiles.Count Then
                shape.Fill.UserPicture selectedFiles(i)
                i = i + 1
            Else
                Exit For
            End If
        Next shape
    End If
End Sub
So I use a combination of both vbas then copy the resulting images in shapes as paste them in the main document.
Any way to combine them?

Regards, Nubuki.
Reply With Quote