In this tutorial, as for all the code in this manual, we will use early binding. To enable Maxsurf within your VBA script using early binding you must first reference the Maxsurf Object Library in the Visual Basic environment. To do this, select the Tools | References command from the main menu.

Figure 10 The references dialog. Accessed via Tools | References, from the main menu.
Search the list of items displayed in the resulting dialog and find the Maxsurf 1.0 Automation Library entry. To enable Maxsurf, simply click in the check box to its left and then press OK to exit the dialog. If the reference is set up correctly you will get the benefits of automatic assistance in the editor as you write your macros or scripts. Amongst other things, this will automatically list the properties and methods of objects as you write VBA code (intellisense).
Troubleshooting:
If Maxsurf Does not Appear in the
References Dialog
See Initial Settings on page 16 for the procedure to register the Maxsurf Automation Library with Windows.
The VBA subroutine below is a simple script that uses Maxsurf automation. Type this script into the VBA programming environment.
Dim msApp As New Maxsurf.Application
Public Sub Tutorial_1()
Dim msDesign As Maxsurf.Design
Set msDesign = msApp.Design
'Creates a surface in Maxsurf
msDesign.Surfaces.Add msSLDefault
End Sub
Before running this script, make sure Maxsurf is running and a new design has been started (File | New Design). Now run this script from the VBA environment, it creates a new surface in the current Maxsurf design. To check this, you may want to turn on the control point net, or rendering.