Migrating from Visual Basic to VBA

3 4

If you are considering migrating from Microsoft Visual Basic to Microsoft Visual Basic for Applications (VBA), keep the following issues in mind:

  • Who will use your solution and which version of Microsoft Visio they use.
  • VBA programs are not compatible with earlier versions of Visio. If you open a document created with Visio 4.5 or later in Visio 4.0 or earlier, Visio opens the drawing, but the VBA programs are not accessible—there is no Macros submenu. Users will not be able to run your VBA program.

  • Visio object types are not compatible with versions earlier than Visio 4.5. If your users are using earlier versions of Visio, you cannot use the Visio type library or Visio object types. To use Visio constants in your program, set a reference to the Microsoft Visio 2002 type library in Visio.

If you do decide to migrate your application from Visual Basic to VBA, you might want to check the following items in your program:

  • Remove CreateObject, GetObject, and vaoGetObject references from your code.
  • You do not need to get an Application object reference when programming in the VBA development environment in the Visio engine. If you are programming in another application's VBA development environment, such as Microsoft Excel, you still need these references to get or create a Visio instance, but when you are programming with the Visio engine, the Visio instance is already running.

  • Transfer code.
  • What components does your code use? Does it use custom controls that are not installed in VBA? Does it use Visual Basic forms? Find out if VBA supports the forms and the custom controls. If it does, you can import the forms from your Visual Basic projects into a VBA project and add any custom controls. If it does not, you could create a new user form in VBA and copy and paste between Visual Basic and VBA project items.

  • Check for code that opens templates and stencils.
  • VBA programs are stored in Visio files. If you store your VBA program with a template that opens the stencils containing the shapes you use in your program, you do not have to take the extra step in your program to open the template and stencils because they are already open, just as a Visio instance is already running.

  • Digitally sign your VBA projects.
  • VBA projects that are stored in your templates or stencils must be signed with a digital signature to work seamlessly in secure environments.



Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net