• Word Template: Extract Photos from a Directory

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Word Template: Extract Photos from a Directory

    Author
    Topic
    #477871

    Hello,

    I have a word template/form that users need to place photos into (numerous photos). Each photo has to be formatted to particular dimensions. I placed a “Picture Content Control” into the template which allows the user to select a source photo with a single click. This process brings in a photo at the preset size. The Picture Content Control is in an external file, which is called into the template by macro. Currently, the user clicks an embedded macro button from the template to call in a table holding the Picture Content Control. I would like to instead, have the user press an embedded macro which will collect all of the photos they have in a photo directory, inserting a picture content control and a photo based on how many photos they have total.

    So for example. If the user has 10 photos, and they place all 10 photos into a child folder named “Photos”, when they activate the macro, the following occurs:

    1. A second Macro is called to insert a table and a Picture Content Control from an external file: the Picture Content Control is activated and Photo1 is selected.
    2. If there is a second photo (Photo1[+1]), the macro (which inserts the table with the Picture Content Control) is called to insert a table and a Picture Content Control from an external file; the second Picture Content Control is activated and Photo2 is called into Picture Content Control #2. If there is not a Photo2, then end.
    3. Repeat Step 2 for Photo2(+1) until all photos are placed.

    If there is a Photo1, and Photo 4, but not a Photo 2 or Photo 3, then same effect as if there was a Photo 1, Photo 2, etc.

    I intend for the user to take photos with their camera which defaults to naming the pictures sequentially. They then place their photos into a designated Photo directory. They then create a new word doc file based off of a template. In the template, the User runs a macro which populates the Word doc with structured tables and formatted photos based on the photos they placed into their designated Photo directory. From there, the user is able to complete the remainder of the form (part of the table inserted with the Picture Content Control)

    Anyone have any suggestions, code runs, starting points, etc?

    Viewing 2 reply threads
    Author
    Replies
    • #1288831

      There are many threads in the past that automated the basic Insert>Picture>From File functionality in earlier versions of Word. I don’t know whether any of those could be adapted to have the intermediate step of inserting a Picture Content Control, but if you’ve already got that code, I don’t see why not.

      By the way, which version of Word are you running?

      • #1288991

        I am running 2010. Some of the users are running 2007.

        I am still having trouble with the import of the pictures. Right now, the user has to import each picture manual by clicking the picture content control element. The user then presses a button/macro that inserts a new table (with a new picture content control) and then inserts a new picture. I would like to have all of their pictures (in a picture dump folder) inserted automatically for them. For this to happen, the AVB would need to:
        1. Count photos in dump folder.
        2. Move to the end of the document.
        3. Run the macro to insert the table w/content control.
        4. Select the picture content control in the table nearest to the end of the document.
        5. Place photo1 into the picture content control in the table.
        6. Repeat 1 through 5 until photo count = 0
        7. End

        I dont know how to count the photos. The photos will have names like 71420110001, 71420110002, 71420110003, 71420110004, etc. defaulting from the camera. I assume a variable Phcnt=0 something Phcnt+1 is needed.

    • #1289866

      You don’t need to count the photos; Word can work through a list of the file names. I am not familiar with the picture content control, so it’s hard to build a sample.

      • #1289924

        Well, I really do not need the picture content control (PCC). I am using the PCC only because you can format the size/shape of the content control so that each picture comes in at the same size. I just need the photos in there, each one in its own table, and each one formatted to the correct size.

    • #1292086

      It sounds like Picture Manager is not installed, and if not, then that might be very helpful. It’s a part of Office 2010 you have bought and paid for but that is not installed by default.

      Start > All Programs > Microsoft Office 2010 > Microsoft Office Tools > Microsoft Office Picture Manager. You might scoop up any other interesting-sounding never-installed goodies while you’re there. You may find that Picture Manager is exactly what you want, and the apparent complexity of your problem will suddenly approach zero. Or, as the old Kodak slogan had it: You push the button, we do the rest.

    Viewing 2 reply threads
    Reply To: Word Template: Extract Photos from a Directory

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: