Migrating VBA to CONNECT


Content related to migrating MicroStation VBA customizations to MicroStation CONNECT.

The MicroStation CONNECT VBA help file (..\MicroStationVBA.chm) provides a few topics that we recommend looking at first:

  1. "Changes for 64-bit Processes"
  2. "MicroStation VBA Environment Variables"
  3. "Calling DLL functions from VBA"

RELATED:

The following items allow you to view notes specific to various VBA API areas:

Architecture
Best Practices
  1. Determine if a Customization Needed
    Check existing Product Features, Workflows and Utilities to leverage first. If none exist and important enough consider submit a forum Idea or, filing a Enhancement Request with the product support team.  Lastly, identify the most appropriate API and determine if it permits you to fulfill the requirements.
  2. Compile your VBA Projects
    Microsoft VBA projects whether saved as for MicroStation VBA (.MVBA files) or Microsoft VBA (Supported Office file formats, or other 3rd party software vendors of VBA engine) all have the potential to cache binary changes from the client computer where the VBA project developer last modified a file. These changes can be subtle version differences from one computer to the next (and not update), show as missing references (not registered or blacklisted controls), or introduce subtle and/or strange behaviors; like: I made changes yet can't see them occuring, objects not created that should be, debugging not entering break points, etc.  In every case it is best to ensure every Class, Form, and Modules has 'Option Explicit as the first line of code and then attempt to Debug > Compile <ProjectName>.  This can most likely identify problems the developer environment may be hiding to to "binary project caching issues".  Typically, once each previously unaddressed error is corrected the project may return to normal.  When in doubt, Export all Class, Form, and Modules from your Project and import them into a brand new Project - add/link available installed Reference modules as needed, test and deploy for user acceptance feedback.
  3. Branch your Source Code
    When significant migration efforts are required it is best to make sure the old code is as stable and clean as possible before migrating to the new platform. Once your old code compiles cleanly helping resolve underlying undefined behaviors (anomalies) make a copy of that code to a new location that you plan is only intended for that software product and not be "shared" between product versions again.  This will help ensure your coding efforts should provide a cleaner implementation of code is moved or created forward.  Cleaner code is more easy to rationalize and debug for you and other developers on the project.
Configuration
Coordinate UnitsSome methods may require UOR input vs. Master Unit values, though most should take Master Unit values.  These will likely be corrected in future releases when found.
  • Recommend: To provide Point in UORs multiply (or scale) master unit point values (X,Y and Z) respectively using: ActiveModelReference.UORsPerMasterUnit.
  • Known Issues: GetFloodBoundary (Defect 541573, Resolved in Update 11)
Database
Load and Run VBA Macros
  • To Load and Run a VBA Macro
    1. Open the VBA Projects dialog (Drawing > Utilities > Macros > VBA Manager)
    2. Select Load Project
    3. Select the desired VBA macro and then select Play
  • To Load and Run a VBA Macro Using a Key-in
    • VBA RUN [project name]module name.subprocedure
    • NOTE: MicroStation CONNECT Edition Update 12 (and later) no longer require "MACRO" to precede the "VBA RUN" key-in syntax.
  • VBA Projects Dialog
  • REF - Add the following key-ins to ensure MicroStation VBA application commands are available; by Silently Loading:
    • MDL SILENTLOAD ustnvba
    • MDL SILENTLOAD Bentley.Macros.UI
Security
  • Determine if your MicroStation VBA Project requires running in a High Security mode. See: Security Configuration Variables:

    MS_SECURITY_LEVEL   : System         = NONE  
    MS_SECURITY_SPC     : System         = C:\ProgramData\Bentley\CONNECT Edition\Configuration\Organization\SPC\*.cer  
Text
  • Known Issues
TroubleShooting