Create VB code in Visio to take a pciture folder and import photos as thumbnails

Posted on 2009-02-24
Last Modified: 2012-08-13
I have a folder of photos of employee pictures. I want to create a VB script that takes all the photos inthe directory and imports them into a page in vizio all the same size.

Is this possible?
Question by:michael_krell
    1 Comment
    LVL 30

    Accepted Solution

    You can certainly do what you're asking. I've provided some starter code that you should put into the VB Editor in Visio. It will loop through all jpg files in a directory (you can change the directory and use a different image file type).

    To get the code you need to open and place the images, the best thing to do is use the Visio macro recorder.
    • Select Tools/Macro/Record New Macro...
    • Manually insert an image file, place it where you want it, and resize it
    • Stop the macro recorder
    • go to the VB editor window to see the code Visio generated
    • Place the appropriate parts of the generated code into Sub ProcessFile()
    After that you'll need to tweak the code the place each new image is a different location on the page. I'll be happy to help with that when you've gotten this far.

    Sub ProcessAllFilesInDirectory()
        Dim PathName As String
        Dim PathAndFileName As String
        ' change path name to your path name
        PathName = "C:\temp\"
        ' line below assumes jpg images; change if images are a different type
        PathAndFileName = PathName & "*.jpg"
        ' Find the first file from the directory (not necessarily the first alphabetically)
        CurrentFileName = Dir(PathAndFileName)
        Do While CurrentFileName <> ""
            ProcessFile (CurrentFileName)
            ' Find the next file in the directory
            CurrentFileName = Dir
    End Sub
    Sub ProcessFile(ByRef FileName As String)
        ' insert image, resize it and position it on the page
    End Sub

    Open in new window


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This collection of functions covers all the normal rounding methods of just about any numeric value.
    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now