Hi folks,

Axiovision is a software that's written in VBA, which allows users to operate on images generated by certain microscopes. These images have the .zvi file extension.

I am trying to write a script in VBA to check all subfolders in a folder, open a particular image in each subfolder, perform a series on operations on the image (which is a macro recorded in Axiovision assigned the key "F9"), then move on to the next subfolder.

The code I have written so far runs, but unexpectedly stops by placing a breakpoint on a random part of the inner loop. The code is as follows:

Sub loopThroughFolders()

Dim basePath, fileSearch, subFolders, fileName, shellCommand, folderPathString, filePathString, filePath as String

basePath = "F:\Petrography Images"
fileSearch = "*Mosaix.zvi"
subFolders = Dir(basePath, vbDirectory)

Do While subFolders <> ""
If subFolders <> "." And subFolders <> ".." Then
folderString = basePath & subFolders
If GetAttr(folderPathString) = vbDirectory Then
filePathString = folderPathString & "" & fileSearch
fileName = Dir(filePathString, vbDirectory)
filePath = folderPathString & "" & fileName
shellCommand = "Explorer.exe " & filePath
SendKeys "{F9}"
End If
End If
subFolders = Dir()
Loop
End Sub
Any ideas where I'm going wrong please? Any help would be much appreciated!