Questions similar to these appear in the Be Communities MicroStation Programming Forum.
This page lists some solutions to common MicroStation VBA (MVBA) problems. Tips are published as examples and are not necessarily working code.
The Next File tool was developed in response to a request by a MicroStation CONNECT user. He had a BASIC macro from the last century. Because BASIC is not supported by MicroStation CONNECT, he wanted a VBA equivalent. Then somebody asked: "Can I have the Next File tool for MicroStation V8i?" and here we are!
The purpose of the tool is to let a user move through the collection of DGN files present in the same folder as the active DGN file. It's a shortcut that saves time by avoiding MicroStation's File|Open menu. Additional capability lets you key-in a command that simulates the user interface, so you can, for example, use function keys to open the next file.
Load the VBA project using key-in
vba run [FileOpener]modMain.main
The DGN File Browser VBA UserForm pops.
The UserForm shows the current DGN file (the active DGN file).
The Previous and Next buttons let you open another DGN file in the same folder as the active DGN file.
With the DGN File Browser showing, you can use another key-in to move through your DGN files …
vba run [FileOpener]modMain.NextFilevba run [FileOpener]modMain.NextFile +vba run [FileOpener]modMain.NextFile -Put those last two key-ins in a MicroStation Function Key Menu or custom user interface widget.
You don't need to know anything about VBA to use our tool. If you're not interested in the description of the VBA code that follows, then skip to the download section.
The ChangeFile BASIC macro (ChangeFile.ba) has been around for a while.
This VBA project provides similar functionality plus a user interface.
Furthermore, it's available for MicroStation CONNECT, where BASIC is unsupported.
VBA class clsNextFile is the primary data holder.
On first loading, clsNextFile builds a list of DGN files found in the same folder as the active DGN file.
It maintains an index to the current active DGN file.
It provides methods to get the next or previous DGN file name in that list.
VBA UserForm frmNextFile is the primary user interface.
The Previous and Next buttons call the corresponding method in class clsNextFile.
Subroutine NextFile simulates a key-in command.
If the Next File tool is not already loaded and showing its UserForm,
then this procedure does nothing.
If the UserForm is displayed, then this subroutine simulates pressing either the
Previous or Next button.
The optional argument (+ or -) specifies the direction to move.
You can download the Next File MVBA project.
The project includes the MVBA project SequentialFileOpener.mvba.
..\Workspace\Standards\vba vba run [FileOpener]modMain.main
UserForm
If you would like to use this macro with MicroStation CONNECT, visit the Next File for CONNECT page to download a valid project.