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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

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

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?
0
michael_krell
Asked:
michael_krell
1 Solution
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
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
    Loop
    
End Sub
 
Sub ProcessFile(ByRef FileName As String)
 
    ' insert image, resize it and position it on the page
 
End Sub

Open in new window

0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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