crrot.blogg.se

Visual basic for excel help
Visual basic for excel help




visual basic for excel help

UserChoice = MsgBox ("Distance is too great.", vbOKCancel) If you use the return value from a function, you must surround the arguments to the function with parentheses. If you are not using the return value of the function you may choose to use the Call statement or not, following the guidelines above.

visual basic for excel help

When you use just the name of the sub procedure, the parentheses should not be used.Ĭalling a function is similar to calling a sub procedure. Note: when you use the Call statement, you must put parentheses around the arguments for the procedure. Or, just use the name of the sub procedure followed by any arguments it requires, like this: When you call a sub procedure, you can either use the Call statement, like this:

visual basic for excel help

The primary difference between them is that a function returns a value to the statement where it was called, and a sub procedure does not. The most common types of methods in VBA are sub procedures and functions. View1.Zoom 3.0 Calling sub and function procedures Using the zoom method to increase magnification by a factor of 3.0 in the view “view1” looks like this: The Zoom method requires a value for setting the zoom factor. For instance, the View object has a Zoom method for zooming in. Methods often require arguments that determine specifically how the action is performed, or with what information it is performed. To calculate the area enclosed by the ShapeElement object “shape1”, you would use the following line:

visual basic for excel help

For example, the ShapeElement object has an Area method. The Help topic for each property indicates whether it is “Read/Write” or “Read-only”.Ī “method” is an action that an object can perform. When object properties can only be “read” in this fashion and are not changeable, they are said to be “Read-only” properties. If element1.isPlanar = True Then element1.Color = 1 To continue with the same example, the following line sets the color of line element “element1” to blue if it is planar: Since this is a test of whether the object meets the specific condition, it is useful for taking action based on that condition. Some object properties cannot be changed, for example the IsPlanar property is used to test whether an element lies completely in one plane. For example, to change the color of a line element object named “element1” to red, you would use the following line: To set the value of a property, use the name of the object followed by a period and the name of the property, an equal sign, and the new value for the property. For example the IsLocked property can be used to set an element's locked status. Properties can also affect the behavior of the object. A property is an attribute of an object, such as color, line weight or style. Most objects, especially objects that represent drawing elements, have properties. There are three types of items within a project: What's inside a VBA project?Ī VBA project is normally a collection of several VBA items related to a specific task or operation. The square brackets must surround the name of the project to be loaded. To load a VBA project and run a macro within it: With one command, a project can be loaded and a macro within the project initiated, but only from the Keyin window in MicroStation. Loading and running a macro with one command

  • Select the macro to run, then click Run.Īlternative method of running a macro from a loaded VBA project:.
  • The list then shows only macros in the selected project.
  • In the Macros In: pull-down list, choose the project containing the macro you wish to run.
  • Click the Macros button in the Project Manager dialog box.Ī list of macros in all currently loaded projects appears.
  • Select Utilities> Macro> Project Manager.īefore running a macro, first make sure the project that contains it is loaded.
  • The project appears in the VBA Project Manager dialog box.Īlternative method of loading a VBA project:
  • From the Load Project dialog box, choose the VBA project file (*.mvba) to load.
  • Click the Load Project icon in the toolbar.
  • Select Utilities > Macro > Project Manager.
  • Loading a projectĪ project is usually a complete collection of the VBA components for a particular macro or set of macros. Before you can run a Visual Basic macro in MicroStation (VBA programs are often called macros) you must first load the VBA project within which the macro resides.






    Visual basic for excel help