[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Add multiple screenshots to Word (2010)

Posted on 2012-09-17
14
Medium Priority
?
833 Views
Last Modified: 2012-09-18
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
Comment
Question by:janhoedt
  • 7
  • 6
14 Comments
 
LVL 14

Expert Comment

by:athomsfere
ID: 38405460
I would use a Macro.

Basically, you want it to create a two column row for each image.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38405497
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
 

Author Comment

by:janhoedt
ID: 38405506
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:janhoedt
ID: 38405529
Looks great! Pictures fit also!
One more thing: I sorts the pictures picture (1).jpg, then picture (10).jpg etc instead of  2 ....
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38405590
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
 

Author Comment

by:janhoedt
ID: 38405631
I used the rename tool of Windows (select all, rename first, rest is automatically renamed). Not sure how to continue now.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38405664
Is there still a problem?
0
 

Author Comment

by:janhoedt
ID: 38405728
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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 38405832
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
 

Author Comment

by:janhoedt
ID: 38408459
Cheers, but I get an empty Word document, pictures are not added.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38408484
The name isn't quite right. I mistyped the file extension as .jpg).

This needs correcting on lines 18, 22 and 24
0
 

Author Comment

by:janhoedt
ID: 38408541
Result is the same.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38408561
Is the file name and path  correct? Try adding this line after line 18

MsgBox strFile
0
 

Author Comment

by:janhoedt
ID: 38408583
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question