Consulting

Results 1 to 2 of 2

Thread: Import Multiple Pictures with some specifications into Word

  1. #1
    VBAX Newbie
    Joined
    Nov 2015
    Posts
    2
    Location

    Question Import Multiple Pictures with some specifications into Word

    Hi All!
    I have an important problem to solve... I want to import several pictures in a Word File. The source are pictures from a camera, so some in landscape some in portrait with a very high resolution.
    The ideal resultvwould:
    - compress the pics first (300/600dpi) to keep filesize low and Word do not hang up itself
    - arrange the Pics in a given order (so I can switch Pic 23 with Pic 45)
    - the final size of the pics are all the same (width/height) but the ratio remains as the original and maximum 4 pics are arranged on 1 DIN A4 page
    - below each pic is a description with the file name
    - possibly the pic and the description line are in two lines of a table so that all pics and descriptions are fitted in a table

    A guy from this forum posted the code below which sounds interesting in the description but gives not a solution for all requirements and unfortunately has an syntax error:
    Sub FitPics()
    Application.ScreenUpdating = False
    Dim Tbl As Table, Ishp As InlineShape
    With ActiveDocument
    ForEach Tbl In.Tables
    ForEach Ishp In Tbl.Range.InlineShapes
    With Ishp
    .LockAspectRatio = msoTrue
    If .Height > .Range.Cells(1).Height Then
    .Height = .Range.Cells(1).Height
    End If
    If .Width > .Range.Cells(1).Width Then
    .Width = .Range.Cells(1).Width
    End If
    If .Width < .Range.Cells(1).Width Then
    .Width = .Range.Cells(1).Width
    End If
    EndWith
    Next
    Next
    EndWith
    Application.ScreenUpdating = True
    EndSub

    Can U help?!?

    Thank you very much in advance

  2. #2
    The syntax errors in the macro are simply due to some missing spaces ForEach should be two words as should EndWith.
    Take a look at http://www.gmayor.com/photo_gallery_template.html. A two column format should do more or less what you want. The pictures are insereted in the order they are selected.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •