Share via

I need help developing a macro that will do 6 pictures per page in two columns with room for text below.

Anonymous
2023-02-21T19:37:13+00:00

I have no idea where to start. Any help is appreciated. Sometimes I have 300 photos to import

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

10 answers

Sort by: Most helpful
  1. Charles Kenyon 167.1K Reputation points Volunteer Moderator
    2023-02-21T21:43:09+00:00

    @Anna,

    This looks like you are using Windows filepaths rather than Mac. (I know, he posted in the Windows forum.)

    John Korchok gave the code for a platform-independent file separator in this thread. https://answers.microsoft.com/en-us/msoffice/forum/all/makro-to-automate-the-pdf-coversion/8996f5cb-0d07-4f07-a530-f1a591b879bd

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-02-21T22:21:00+00:00

    Thanks. is there a way to just select a group of photos that may be in a particular folder or do I need to pre-define the path to find the photos?

    Thank you for all of your help!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-02-21T20:40:56+00:00

    To find your user folder path, you can follow these steps:

    Open Finder Click on your username in the sidebar (usually at the top of the list). Click on the "Pictures" folder. From the menu bar, select "View" and then "Show Path Bar". The path to your Pictures folder should appear at the bottom of the Finder window. It should look something like "/Users/your-username/Pictures".

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-02-21T20:28:56+00:00

    THANK YOU SO MUCH for getting me started.

    I am getting an error message on this line. I am on a MAC so that may be a problem can it be a generic name/location for the photo?

    It looks like this is going to the c drive which I do not have.

    Selection.InlineShapes.AddPicture FileName:="C:\Pictures\Pic" & i & ".jpg", _ LinkToFile:=False, SaveWithDocument:=True

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-02-21T20:15:00+00:00

    Hi Johnson

    I'm AnnaThomas and I'd be happy to help you with your question. In this Forum, we are Microsoft consumers just like yourself.

    You can follow these steps:

    Open a new or existing Word document. Go to the "View" tab in the ribbon and click on "Macros." In the Macros dialog box, give your macro a name, such as "InsertSixPictures." Click on "Create" to open the Visual Basic Editor. In the Visual Basic Editor, you will see the code for the macro. Insert the following code:

    Sub InsertSixPictures() 'Set up the page layout With ActiveDocument.PageSetup . Orientation = wdOrientPortrait . TopMargin = InchesToPoints(0.75) . BottomMargin = InchesToPoints(0.75) . LeftMargin = InchesToPoints(0.75) . RightMargin = InchesToPoints(0.75) . Gutter = InchesToPoints(0) . HeaderDistance = InchesToPoints(0.5) . FooterDistance = InchesToPoints(0.5) . PageWidth = InchesToPoints(8.5) . PageHeight = InchesToPoints(11) . TwoPagesOnOne = False . LineNumbering.Active = False . TextColumns.SetCount NumColumns:=2 . TextColumns.EvenlySpaced = True . TextColumns.LineBetween = False . TextColumns.Width = InchesToPoints(3.5) End With

    'Insert the pictures Dim i As Long For i = 1 To 6 Selection.InlineShapes.AddPicture FileName:="C:\Pictures\Pic" & i & ".jpg", _ LinkToFile:=False, SaveWithDocument:=True Selection.TypeParagraph Next i

    'Insert the text Selection.TypeText Text:="Text goes here" End Sub

    In the code above, modify the file path and names of your pictures (Pic1.jpg, Pic2.jpg, etc.) as needed. Save and close the Visual Basic Editor. To run the macro, go to the "View" tab in the ribbon and click on "Macros." Select your macro from the list and click "Run."

    I hope this helps ;-), let me know if this is contrary to what you need, I would still be helpful to answer more of your questions.

    Best Regards,

    AnnaThomas

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    Was this answer helpful?

    0 comments No comments