• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 877
  • Last Modified:

Add multiple screenshots to Word (2010)

Hi,

Via FastStone Capture I have made automatic screenshots of settings of a certain program (230 screenshots in total). Now I would like to add them to Word in a table.

Goal: have all screenshots in the left column, add explanation in the right column.

Example of what I mean:
word
Please advise how to do this.

J.
0
janhoedt
Asked:
janhoedt
  • 7
  • 6
1 Solution
 
athomsfereCommented:
I would use a Macro.

Basically, you want it to create a two column row for each image.
0
 
GrahamSkanRetiredCommented:
This macro shows how to create the document and table, and how to insert the pictures in the first column. It puts the file names in the second column.

Sub CreateGallery()

    Dim ilsh As InlineShape
    Dim strFolder As String
    Dim tbl As Table
    Dim strFile As String
    Dim rw As Row
    Dim doc As Document
    
    Set doc = Documents.Add
    Set tbl = doc.Tables.Add(doc.Range, 1, 2)
    Set rw = tbl.Rows.First
    rw.cells(1).Range.Text = "Picture"
    rw.cells(2).Range.Text = "File"
    strFolder = "C:\My Pictures"
    
    strFile = Dir$(strFolder & "\*.jpg")
    Do Until strFile = ""
        Set rw = tbl.Rows.Add
        doc.InlineShapes.AddPicture strFolder & "\" & strFile, False, True, rw.cells(1).Range
        rw.cells(2).Range.Text = strFile
        strFile = Dir$()
    Loop

End Sub

Open in new window

0
 
janhoedtAuthor Commented:
Ok, thanks! I'll try it right away. Then again, pictures seem to big, how can I adjust/resize them all in 1 go, so they fit?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
janhoedtAuthor Commented:
Looks great! Pictures fit also!
One more thing: I sorts the pictures picture (1).jpg, then picture (10).jpg etc instead of  2 ....
0
 
GrahamSkanRetiredCommented:
The macro makes no attempt to sort them, but if it did, that would be the order with a simple alphabetic sort. It might be worth inserting leading zeros into those names with less that the maximum number of digits.
0
 
janhoedtAuthor Commented:
I used the rename tool of Windows (select all, rename first, rest is automatically renamed). Not sure how to continue now.
0
 
GrahamSkanRetiredCommented:
Is there still a problem?
0
 
janhoedtAuthor Commented:
Rename tool of Windows gives me name(01).jpg, name(02).jpg. But this makes it to be sorted wrong since the macro puts name(01).jpg, then name(10).jpg, then name(100).jpg instead of (01).jpg, (02).jpg etc. Sorting column in Word doesn't solve it either.
0
 
GrahamSkanRetiredCommented:
See if this helps:
Sub IncrementThroughFolder()

    Dim ilsh As InlineShape
    Dim strFolder As String
    Dim tbl As Table
    Dim strFile As String
    Dim rw As Row
    Dim doc As Document
    Dim i As Integer
    
    Set doc = Documents.Add
    Set tbl = doc.Tables.Add(doc.Range, 1, 2)
    Set rw = tbl.Rows.First
    rw.cells(1).Range.Text = "Picture"
    rw.cells(2).Range.Text = "File"
    strFolder = "C:\My Pictures"
    i = 1
    strFile = strFolder & "\Picture(" & i & ").jpg)"
    Do Until Dir$(strFile) = ""
        Set rw = tbl.Rows.Add
        doc.InlineShapes.AddPicture strFile, False, True, rw.cells(1).Range
        rw.cells(2).Range.Text = "Picture(" & i & ").jpg)"
        i = i + 1
        strFile = strFolder & "\Picture(" & i & ").jpg)"
    Loop

End Sub

Open in new window

0
 
janhoedtAuthor Commented:
Cheers, but I get an empty Word document, pictures are not added.
0
 
GrahamSkanRetiredCommented:
The name isn't quite right. I mistyped the file extension as .jpg).

This needs correcting on lines 18, 22 and 24
0
 
janhoedtAuthor Commented:
Result is the same.
0
 
GrahamSkanRetiredCommented:
Is the file name and path  correct? Try adding this line after line 18

MsgBox strFile
0
 
janhoedtAuthor Commented:
Great! It was a space that I had to add, works perfectly now, thanks!
Sub IncrementThroughFolder()

    Dim ilsh As InlineShape
    Dim strFolder As String
    Dim tbl As Table
    Dim strFile As String
    Dim rw As Row
    Dim doc As Document
    Dim i As Integer
    
    Set doc = Documents.Add
    Set tbl = doc.Tables.Add(doc.Range, 1, 2)
    Set rw = tbl.Rows.First
    rw.Cells(1).Range.Text = "Picture"
    rw.Cells(2).Range.Text = "File"
    strFolder = "\\RES.SYS.SHARED.FORTIS\Users\I38\I38808\UserData\Desktop\printscreens"
    i = 1
    strFile = strFolder & "\Picture (" & i & ").jpg"
    MsgBox strFile
    Do Until Dir$(strFile) = ""
        Set rw = tbl.Rows.Add
        doc.InlineShapes.AddPicture strFile, False, True, rw.Cells(1).Range
        rw.Cells(2).Range.Text = "Picture (" & i & ").jpg"
        i = i + 1
        strFile = strFolder & "\Picture (" & i & ").jpg"
    Loop

End Sub

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now