Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
MicroStation Programming
  • Product Communities
  • Developers and Programming
  • MicroStation Programming
  • More
  • Cancel
MicroStation Programming
MicroStation Programming - Wiki Simple example with recording code
    • Sign in
    • MicroStation Programming - Wiki
    • -MicroStation CONNECT Edition
      • +MicroStation SDK
      • +MicroStation MDL
      • -MicroStation VBA
        • +MVBA FAQ
        • -MVBA Topics
          • CRUD example
          • Debugging
          • Documentation
          • Migration from VBA 6.x to 7.x
          • +MVBA Transforms
          • Network Shared Projects
          • Object model
          • Simple example with object library
          • Simple example with recording code
          • VBA Editor
          • VBA Integration with Applications
      • +Training
      • +Code Examples and Utilities
      • +Code Snippets
    • +MicroStation V8

     
     Questions about this article, topic, or product? Click here. 

    Simple example with recording code

    Simple Example – recorded VBA macro

    There are different development levels to create VBA code create or manipulate and remove data.

    One method is to execute commands in MicroStation and record these steps as a macro and save this as VBA code. There are just a view steps required in order to get a recorded macro:

    Go to the Utilities Tab of the Ribbon menu and select the “Record” button within the Macros Ribbon:

    Please note: with a click on the “Record” button the button changes to “Pause” to let us know the steps from now are recorded.

    After executing the desired steps in MicroStation a click on “Stop” ends the recording and a new dialog opens to ask for a project name to save the macro:

    Please note: the Button in the lower left corner. This button expands the dialog and allows to select between “Bentley” and “VBA”. If the default “Bentley” is selected, the recording is saved as binary BMR format.

    Please select “VBA”, browse to the desired location and press “Save”. This will save the project in a new MVBA project file. The name of the VBA project just used to save the recording is now also added into the Macros Ribbon, please note the entry “Bmrrecordtest”:

    A click on the pencil symbol on the right of the name opens the VBA editor with the previous created VBA macro:

     

    For this recording I used the “Place Smartline” keyin in MicroStation and in the recorded VBA code I can find this line:

    CadInputQueue.SendKeyin " PLACE SMARTLINE"

    This is how a MicroStation keyin is used in a VBA program to start a command. To learn more about the .SendKeyin method click on the word to position the cursor for context sensitive help and press the F1 key for help. This will open the MicroStation VBA help and show the help like this:

    If you want to learn more about “CadInputQueue” do the same or search directly in the help:

    Please note: Some keywords on the help provide link to code example, like here for CadInputQueue. If you click on “Example”, you may select from a larger number of examples:

    If just select the first example to get this complete VBA code example:

    Within the MicroStation VBA help there are a lot of code examples to demonstrate the use of the different methods. Please note: Make sure to use a MicroStation keyword before using F1 for sensitive help, otherwise the general VBA help opens, which helps with general VBA keyword, but does not contain help for MicroStation  classes.

    The MicroStation VBA helpfile can also be opened outside the VBA Editor. The name of the help file is MicroStionVBA.chm and is stored in the same folder with MicroStation.exe.

    • Documentation
    • VBA Programming
    • VBA
    • Share
    • History
    • More
    • Cancel
    • Artur Goldsweer Created by Bentley Colleague Artur Goldsweer
    • When: Fri, May 22 2020 6:00 AM
    • Artur Goldsweer Last revision by Bentley Colleague Artur Goldsweer
    • When: Fri, May 22 2020 6:13 AM
    • Revisions: 2
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies