The ABCs of VBA CP21-2. R. Robert Bell - MW Consulting Engineers

Size: px
Start display at page:

Download "The ABCs of VBA CP21-2. R. Robert Bell - MW Consulting Engineers"

Transcription

1 11/29/2005-8:00 am - 11:30 am Room:Swan 7/8 (Swan) Walt Disney World Swan and Dolphin Resort Orlando, Florida R. Robert Bell - MW Consulting Engineers CP21-2 Do you want to customize AutoCAD using VBA but don't know how to get started? This course will demonstrate opening multiple drawings to make a modification to the title block's attributes. You will see the advantages of using VBA for dialog box interfaces and working on multiple drawings. About the Speaker: Robert is the network administrator for MW Consulting Engineers, a consulting firm in Spokane, Washington, where he is responsible for the network and all AutoCAD customization. Robert has been writing AutoLISP code since AutoCAD v2.5, and VBA since it was introduced in Release 14. He has customized applications for the electrical/lighting, plumbing/piping, and HVAC disciplines. Robert has also developed applications for AutoCAD as a consultant. He is on the Board of Directors for AUGI and is active on Autodesk discussion groups. RobertB@MWEngineers.com

2

3 Introduction You are obviously interested in learning how to write code using Visual Basic for Applications. There are some good reasons to learn VBA. Certain features, such as access to the Sheet Set Manager, are only available to non-c++/.net programmers via VBA. The development environment is far superior to that available in Visual LISP. Forms are much easier to do in VBA than in DCL. So the question is, how do you get started? The first part of this course will introduce you to some features of VBA and its syntax. The second part will help you to get started programming in VBA by taking a common request, modifying attributes in multiple drawings, and using VBA to create a program to do the work. This sample application will introduce you to the ABC s of VBA. Glossary of Terms A brief glossary is provided to explain some of the terms you will hear related to VBA. Breakpoint A selected line in the program at which execution automatically halts Class Contains the definition of an object Compile-time The period when source code is translated to executable code, for VBA this means when it is saved Dim Statement used to declare a variable and the type of data it holds Early binding A reference is added to the project and its objects are available while writing the code Event A procedure that executes in reaction to some occurrence Form A window or dialog box that forms part of the user interface Function Type of procedure that returns a result IDE Integrated Design Environment, the editor in which you write code, design forms, and debug applications Late binding Objects are bound only when the code runs, avoiding the need for a reference Macro A public Sub procedure that the user executes The VBA Manager Method A procedure that acts on an object, e.g. Copy, Move, or Delete Module A set of declarations and procedures Object An element of an application, e.g. a form, a control, a layer, or a circle Object Model The objects related to a specific application, and the properties, methods, and events related to those objects Private The item thus declared is available only within the current module or procedure Procedure A named group of statements that execute as a unit Project A set of modules VBA projects are loaded and unloaded with the VBA Manager. Use the VBAMan command to display this manager inside AutoCAD. Loading a project does not automatically execute it. The user, a CUI command, a menu macro, or Visual LISP code must execute the project s macros. The elements of the VBA Manager dialog are straightforward, so there is no need to describe them here. Property 1: A named attribute of an object, such as Center, or Layer 2: Type of procedure that defines or returns data in a class module Public The item thus declared will be available outside the module Run-time The period when compiled code is executed Sub Type of procedure that does not return a result 2

4 The VBA Integrated Design Environment (IDE) The VBAIDE may be displayed using one of two methods. One, you may use the Visual Basic Editor button in the VBA Manager dialog box. On the other hand, you may choose to use the VBAIDE command. Many of the elements of the VBAIDE are described here. The Project Explorer (Ctrl+R) is where you add and remove a project s forms, modules, and class modules. Add any of those elements by selecting the target project, or any of its existing elements, select Insert (from the menu bar or the right-click menu) and choose the type of module or form. You remove a selected element by choosing Remove from the File menu, or from the right-click menu. The Properties window (F4) displays the design-time properties for the selected objects. You can change them 3

5 while writing code in this window. Properties may also be changed at run-time. Some properties can only be changed at run-time. The Immediate window (Ctrl+G) is very useful during debugging. It will display results from debugging statements in your code. You may also type commands directly into the window. You can change the data in a variable during the debug session. You may also observe what the results are of the commands you type in this window. The Locals window (View menu) displays all the variables and their values for the procedure currently running. The Locals window does not display module-level variables. You may change the value of the variables in this window. The Code window (F7) is the most important window, of course. Each object in the Project Explorer may have its own code window. Note the gray border on the left side of the code window. You may add breakpoints and bookmarks there. The Watch window (View menu) automatically displays when watch expressions are defined in the project. Use the Debug menu to add watch expressions. Debugging The debugging tools available in the VBAIDE provide you with a complete package to locate and correct errors. Although this course will not delve into debugging applications here are some of the tools. The Debug object provides the useful Print and Assert methods Breakpoints to pause program execution Stepping thru code line-by-line while in break mode (F8) The Watch and Locals windows Two Options You Must Change The editor has a couple of options that really should be changed from their defaults. The two options are Require Variable Declaration and Auto Syntax Check. I strongly suggest always using the Require Variable Declaration option. This forces you to think about the assignment of variables. It also helps you avoid variable name errors. When this option is active, any new project will have the statement Option Explicit automatically added to any modules or forms. I hate the Auto Syntax Check option. I have never seen an aid get in the way of writing code like this option does! If you begin a line of code, and decide to go grab another line to copy-and-paste, this option will display a message box that your current line has a compile error. Duh. I m working on it, you stupid computer Edit these options by going to the Tools Options menu item. This displays the Options dialog box. Select the Editor tab, clear the Auto Syntax Check option, and check the Require Variable Declaration option. Projects Projects are the container for separate elements such as standard modules, class modules, and forms. They also include references to external libraries which give you access to another application s objects. Projects are saved as.dvb files. To distinguish projects, give them a different name in the Name property. Projects may be embedded in a drawing, but this is uncommon. 4

6 ThisDrawing Prominently available inside all projects created by AutoCAD s VBAIDE is the ThisDrawing object. This unique object always refers to the current drawing, even when a running macro changes the current drawing. Document-level events are available in this object. This is also a common location for code in simple VBA projects. Standard Modules A standard module contains procedures, user-defined data type declarations, and data definitions. Module-level declarations and definitions are Public by default. This means that public Sub procedures will be visible to the user as macros. Module-level Private declarations and definitions are available only inside that module and are concealed from the user. It is possible to have several standard modules in a single project. Name the modules clearly and uniquely within each project. Class Modules This module defines a class. A class defines an object, just as a floor plan defines how a house is built. Class modules use procedures to define methods for the object. Exposed data in the class module act as properties. Class modules also permit you to reuse code without duplication of the code. A class module s name is the name used when creating a new instance of the object defined by the class. Forms Forms are easy to create. It is simply a matter of drag-and-drop. Additional controls are available for purchase or free at many programming-related websites. You must be careful to use only controls in a VBA application that are available directly within VBA or as mentioned previously. Microsoft s EULA prohibits the use of Visual Basic controls, for instance. You may use controls available thru installed applications as long as those applications are installed on all computers that use the VBA application. You display forms with the Show method. Hide them using the Hide method. In VBA, a form cannot be closed, only hidden. Therefore, if you show the form again, you may need to make sure the controls are not duplicating data that existed from the previous display of the form. The form, and each control for a form, has events associated with it. You use those events to react to the user s input and work with the associated data. Events are procedures also, so you write VBA code to work with the form and its controls under those procedures. A form may also have ancillary procedures that are not events themselves. Objects Objects are a combination of code and data that are treated as a unit. A class defines an object. Objects might be visible things such as a form or a control, or within AutoCAD, a layer or a circle. Objects can also be more abstract, such as encapsulating the code that is required to display an Open dialog box, or the code needed to access AutoCAD s Dictionary/XRecords. Objects are a great way to reduce complex code to easy-to-use elements. Procedures Named procedures organize groups of code. Use the Sub or Function statements to declare these procedures. A Sub executes the code but does not return a result. A Function executes the code and returns a result. Both types of procedures can accept arguments. Declare arguments with a 5

7 name and data type. Arguments act as a variable inside that procedure. Arguments may also be declared as optional. Procedures will be Public unless they are preceded with the Private keyword. Arrays, Collections, and Dictionaries Data often need to be grouped together. There are several mechanisms to perform this grouping. Arrays are the basic way this is accomplished. Arrays need to store the same type of data throughout the array, although the type can be a Variant. By default arrays are indexed starting at zero, i.e. the first element in the array is at index 0. You reach each element in the array by providing the variable that holds the array followed by the index enclosed in parenthesis, e.g. myarray(2) returns the third element in the array. Collections are a step up from arrays. A collection is treated as a single object. The members in the collection do not need to be the same data type. You may use the Count property to return the number of members in the collection. The Item property give you access to each member. Note that collections are indexed starting at one, i.e. the first member is at index 1. Members in the collection can be added or removed at any time. Added members may be placed before or after specific members. You can provide a unique key for each member as it is added and retrieve that member by using the key instead of using the Item property. The Scripting Runtime Library provides dictionaries. They go beyond a collection with a few additional properties and methods. Variables Variables need to be declared, or defined as holding specific types of data. The declaration of the variable also sets how the variable name appears in the rest of the code. When you use mixedcased variable names, it becomes easy to determine when you correctly type a variable name. Many experienced programmers use variable names that start with lower-case letters and then use upper-case letters further in the name, e.g. mycircle. Some programmers use the first part of the variable name to describe the type of data the variable stores, but this technique has its negatives. If the type of data needs to be changed at a later point the variable name no longer accurately reflects the data type. A far better approach is to make the variable name simple and clear enough to describe why it is used, e.g. mypickpoint must be holding a coordinate point. Usually, the Dim statement declares variables. For example, the following statement declares a variable named alayout that will hold one of AutoCAD s Layout objects. Dim alayout As AcadLayout Here is another example, this one declaring a variable named mydist as a double, which is a double-precision floating-point number. Dim mydist As Double Arrays are declared by specifying the dimensions of the array and the data type the array will contain. Dim myarray(0 To 1) As String Use the ReDim statement to reallocate an array. Redimensioning an array is expensive in computer time. If you do not know the exact dimensions required for an array at compile-time it is far better to estimate an appropriate size and redimension it only when required. The existing data in the array is deleted unless the Preserve keyword is used. ReDim Preserve myarray(0 To 2) 6

8 Note that you cannot change the type of data stored in the array except in certain conditions. See the VBA help files for more information. VBA Data Types The following list is not exhaustive, but does contain the common data types you will use in day-today VBA programming for AutoCAD. Boolean True or False Double Double-precision floating-point number Integer 16-bit integer Long 32-bit integer Object Object reference String A string of characters Variant Can contain any kind of data, usually used to store an array returned by a function Variables can also be declared to store specific objects. This is most often done with AutoCAD objects for the AutoCAD VBA programmer, but can be done for objects exposed by other classes. Adding a reference to an external library opens this option to you. Doing this is called early binding. The advantages of early binding are an increase in performance and IntelliSense becomes available for the objects in the reference. The disadvantage is that the reference might be version-specific, e.g. adding a reference to Microsoft Office ties your project to that version of Office. Assigning Data to Variables Data are assigned to variables thru the use of the equal sign (=). You place the variable name on the left of the equal sign and the value to the right. If the variable has been declared as an object, you need to use the Set statement. Here are some examples of variable assignments. myage = 29 hrwage = 5.15 mylayername = "0" Set mylayout = ThisDrawing.Layouts.Item("Model") What is IntelliSense? IntelliSense is a feature that makes writing code in the VBAIDE a joy. For instance, IntelliSense anticipates your variable and statement names as you type. Type the first part of the variable name. Hit Ctrl+Space. If the partial name is unique enough, the variable name is completed for you. If there are several possibilities, they are listed for you and you can select the one you need. IntelliSense also works with objects. An object s properties and methods are displayed in a list when you type a period (.) after the object. This reduces trips to the help files to determine the exact property or method name you need to accomplish the desired task. You should plan for this ability when you create a new class. Make sure your property and procedure names are clear enough for anyone using IntelliSense to determine the needed property or method. Once you have used IntelliSense a few times you realize just how easy it makes writing code in the VBAIDE. Going back to the Visual LISP IDE is a painful experience from that point. 7

9 A Couple of Common Mistakes A couple of very common errors frequently occur when you first start writing VBA code. The first one relates to the question of when you need to use parenthesis when calling a function. A function can be called either with or without enclosing its arguments in parenthesis. The rule is that you need to use parenthesis when you are using the result of the function. With that knowledge, determine which of the following examples (that calls a function named GetFiles) are incorrect. A) GetFiles myfiles B) success = GetFiles myfiles C) success = GetFiles(myFiles) Example A) is not incorrect because the return value from the function is being ignored. Example B) is incorrect because the return value is being used yet the argument is not enclosed in parenthesis. Example C) is correct because the function s argument is enclosed in parenthesis and the return value is being used. The other error results from the confusion regarding the use of the Set statement. Remember, you need to use the Set statement only when you assign an object to a variable. Using that knowledge, determine which of the following examples are incorrect. A) mylayername = "0" B) Set mylayername = "0" C) Set mylayout = ThisDrawing.Layouts.Item("Model") D) mylayer = ThisDrawing.Layers.Item(myLayerName) Example A) is correct because the assignment is a string and obviously not an object. Example B) is not correct because the Set statement is being used for a string assignment. Example C) is correct as the variable is being assigned a Layout object and therefore the Set statement is required. Example D) is incorrect because the Layer object is being assigned to the mylayer variable without the Set statement. Making Choices A program will usually need to branch depending on circumstances. A VBA program can branch in several ways. Most common are the If Then Else or Select Case statements. The structure of the If statement is straightforward. A test condition is needed, one that results in either true or false. A Then statement immediately follows the test condition. Code that executes when the condition is true is on subsequent lines. Where code is required when the condition is false you must place an Else statement on a line to itself and its code on lines following that statement. Finally, close the If block with the End If statement. If theskycolor = "Blue" Then MsgBox "You are correct." Else MsgBox "Only in my world." End If There are a couple of variations possible with the If statement. There is a single-line form and the use of the ElseIf statement. These are documented in the VBA help files. If myname = Tim Then WarnOfBeast The Select Case statement is useful when a single expression may have several different values. Each case is evaluated until a match is found. When a match is found the code that follows that case is executed and then the Select Case block is exited. You may also use the Case Else statement to execute code if none of the other case statements are matched. The Select Case block is ended with an End Select statement. 8

10 Select Case favoritecolor Case "Blue" MsgBox "Well, alright then." Case "Yellow" MsgBox "Blue. No! wait yellow..." Case "Green" MsgBox "Hey! That's not in the movie." End Select Looping Programs are usually written to make repetitive tasks simple. Therefore, many programs perform some sort of looping. VBA has many looping constructs. The most common is the For Next loop. The For statement uses a counter to execute its block of code a specific number of times. The Next statement closes the block of code in the For loop and increments the counter. Usually the counter is increased by one each time thru the loop, but you may use the Step keyword to change the increment or reverse the counter. Dim i As Long For i = 1 To 5 MsgBox "The counter is at " & CStr(i) Next i A variation of that type of loop is the For Each Next loop. This form is used to loop thru an array or a collection. You need to declare a variable of the appropriate type before entering the loop. The following example loops thru all the layouts in the current drawing. Dim alayout As AcadLayout For Each alayout In ThisDrawing.Layouts MsgBox "Layout name: " & alayout.name Next alayout You may need to exit the For Next loop depending on certain conditions. This is accomplished with the Exit For statement. You can have multiple Exit For statements in a single For Next loop. Another type of loop in VBA is the Do Loop. This will loop while, or until, a condition is true. Therefore, the loop repeats an indefinite number of times. This is useful when you do not know how many times the loop needs to occur. The Until keyword may be used to make the loop repeat until a certain condition is true. The Exit Do statement will force an exit from within the loop. Odds and Ends A few other items about VBA are worth mentioning. Combine multiple statements on one line by separating the statements with a colon (:). This can be very useful to combine selection set filters, for instance. You will see this in the sample application. At times, you need to split a statement into multiple lines. Accomplish this by using a space followed by the underscore character ( _). The IDE will let you know if you split a statement inappropriately by highlighting the lines in question in red. You may declare multiple variables on one line by separating the variables with a comma (,). Note that you must declare the data type for each variable if you use this approach. Arguments for procedures can be given by name. This is useful when a procedure has multiple optional arguments and you want to provide only a few of those options. A named argument consists of the name followed by a colon and an equal sign (:=) and then the value for the argument. A fine example of this is shown in conjunction with the selection set in the sample application. 9

11 Although you can password protect a VBA application, it is an exercise in futility. The password protection can be easily cracked. Therefore, if you want to develop a secure application, VBA is not the language for you. The AutoCAD Object Model At last, we are ready to discuss the specifics of using VBA to program tasks related to AutoCAD. It is very important to get familiar with the object model of AutoCAD. The absolute best place to see the object model is in AutoCAD s help files. Go to the ActiveX Automation and VBA files, and select the ActiveX and VBA Reference. The first topic in that reference is the object model. The items on that map are clickable. So you can learn about the properties and methods of each object just by clicking on it. Many of the objects also have examples. These examples go a long way in helping to learn how to write VBA code that works with AutoCAD. Take a few moments to walk thru the object model in the context of the sample application. The sample application is going to perform the following tasks: Get drawings to be modified Open one of those drawings Iterate thru all layouts Get all the attributed blocks that are inserted in each layout Show all the attributes and their values for a selected block Change the selected attribute s value in all the drawings Notice how the Application object has a Documents collection. The Documents collection has an Open method that opens a specific Document. Of course, a single Document has a Layouts collection. Each Layout has a Block property (every layout in a drawing is also a block to VBA) which can be used to iterate thru all that layout s objects. We are looking for BlockReference objects. When we find one, we can use its HasAttributes property to see if there are attributes. If there are, we can use the GetAttributes method to get an array of all its attributes. Each attribute for an inserted block is an AttributeReference object. This object has two properties we are interested in: TagString and TextString. 10

12 The Sample Application Now that we know what we need from the object model, we shall determine the procedures for the application. Obviously, we need a main procedure, one that is a Public Sub so that it is a macro visible to the user. It will be called UpdateAttribute. There needs to be a procedure to get the drawing filenames. This will be called GetFiles. It will be a function because it returns filenames. If files were selected, we need a procedure to get all the blocks with attributes from that drawing. An obvious name would be GetBlocks. Once the user selects the desired block via a dialog box, we use the attribute information gathered from GetBlocks to populate a dialog box for the attributes. The user selects the desired attribute and another dialog box is displayed to get the changed value from the user. After all that information is gathered, the drawings the user initially selected need to be processed to make the change to that specific attribute in all the inserted blocks that match the block name. Do you think ProcessDrawings is a good name for the procedure? Of course, there will be some additional procedures to support those primary ones. These ancillary procedures will be developed as the need arises. All the code presented here will be fully commented and downloadable from the Autodesk University website. Creating a New VBA Project Use the VBAMan command to display the VBA Manager. Use the New button to create a new project. Use the Visual Basic Editor button to enter the VBAIDE. Change the project s name to ABCs in the Properties window. Insert a new standard module and name it Main. Two public variables in the main module hold the block information and the attributes for the selected block. This permits the transfer of data from the main module to the forms that need this information. A scripting dictionary will be used to store the block names and the block s attributes. The reasons why a scripting dictionary was chosen will be evident later in the course. A reference needs to be added to the project. Use the Tools References menu item to display the References dialog box. Scroll down to Microsoft Scripting Runtime and select it. Option Explicit Public AllBlocks As Scripting.Dictionary Public AllAttribs As Variant The subsequent sections of the handout describe the program flow for each procedure. UpdateAttribute (The User Macro) A variable to hold the array of selected filenames is declared and populated by another procedure (GetFiles). The storage mechanism for the blocks in a drawing, a scripting dictionary, is created. The public variables from all three forms are initialized. The object did not exist so the New keyword was used. If any files are selected, then the first drawing in the array is opened and the module-level variable AllBlocks is populated by another procedure (GetBlocks). As long as there are 11

13 attributed blocks found, a form is displayed to list the blocks for the user s selection. When a block is picked, its attributes are placed as an array in the module-level variable AllAttribs. Another form is displayed, listing all those attributes and the value found for each one. The user selects an attribute and a final dialog box is shown, to get the changed value of the attribute. If the OK button is hit in that final form, then all the drawings the user selected are processed and the desired attribute s text value is changed. Finally, a dialog box informs the user that the process is complete. Public Sub UpdateAttribute() Dim myfiles As Variant myfiles = GetFiles Set AllBlocks = New Scripting.Dictionary BlockDialog.BlockPicked = "" Set AttribDialog.AttribPicked = Nothing TextDialog.DoUpdate = False If IsArray(myFiles) Then Dim mydoc As AcadDocument Set mydoc = AcadApplication.Documents.Open(myFiles(0)) GetBlocks mydoc, AllBlocks End If If AllBlocks.Count > 0 Then BlockDialog.Show If BlockDialog.BlockPicked <> "" Then AllAttribs = AllBlocks.Item(BlockDialog.BlockPicked) AttribDialog.Show End If If Not (AttribDialog.AttribPicked Is Nothing) Then TextDialog.Show End If If TextDialog.DoUpdate Then ProcessDrawings myfiles, _ BlockDialog.BlockPicked, _ AttribDialog.AttribPicked.TagString, _ TextDialog.NewText MsgBox "Process is complete.", vbokonly, "ABC's of VBA" Else mydoc.close False End If GetFiles The code that is required to display a dialog box for selecting files is lengthy. In addition, this task is needed many times. For this reason, such code is placed in a class module. A search of the Internet will reveal many such class modules. The class module used for this course was downloaded from and slightly modified to permit easier code maintenance. The modification permits you to keep the class module in its own project, yet still use it in your own projects. Note that the original copyright needs to remain with the class module if you choose to use it for your own projects. This modified class module project will be available for download from the Autodesk University website. Make a reference to this separate project. Use the Tools References menu item to display the References dialog box. Change the Files of type option to VBA Project Files. Browse to the location where you saved the class module s project and select it. 12

14 A variable to hold the CommonDialog object is declared. Run the procedure to initialize the object. Various properties for that object are then changed. The CommonDialog class returns a number to indicate success or failure, so a variable to hold that number is declared. The ShowOpen method is used, and its return value is saved to the variable. That return value is examined and if files were selected those filenames are returned as an array. Private Function GetFiles() As Variant Dim myopen As CommonDialogProject.CommonDialog Set myopen = CommonDialogProject.Init myopen.dialogtitle = "Select drawings" myopen.filter = "Drawings (*.dwg) *.dwg" myopen.flags = OFN_ALLOWMULTISELECT + _ OFN_EXPLORER + _ OFN_FILEMUSTEXIST + _ OFN_HIDEREADONLY + _ OFN_PATHMUSTEXIST myopen.initdir = "C:\datasets\CP21-2" myopen.maxfilesize = 2048 Dim success As Long success = myopen.showopen If success > 0 Then GetFiles = myopen.parsefilenames End Function GetBlocks This function requires two arguments, a drawing file to examine and the scripting dictionary that will be storing the block names and the attributes for each block. The first thing done is to change the comparison mode for the dictionary. Since the block names are strings the mode is changed to TextCompare. Variables to hold AutoCAD entities, layouts, and block references are declared. Next, we loop thru all the layouts, ignoring the Model tab. All the entities in each layout are checked to see if it is a block reference (an inserted block). If the entity is a block reference and has attributes, this information is passed to an ancillary procedure (AddBlock). The reason for this ancillary procedure will be clear in a moment. Private Function GetBlocks(ByVal thedoc As AcadDocument, _ ByRef BlockStore As Scripting.Dictionary) BlockStore.CompareMode = TextCompare Dim aentity As AcadEntity Dim alayout As AcadLayout Dim ablkref As AcadBlockReference For Each alayout In thedoc.layouts If Not (alayout.modeltype) Then For Each aentity In alayout.block If TypeOf aentity Is AcadBlockReference Then Set ablkref = aentity If ablkref.hasattributes Then AddBlock BlockStore, ablkref.name, ablkref.getattributes End If End If Next aentity End If Next alayout End Function AddBlock Items in a scripting dictionary are indexed by a key. In this case, the key will be the block name. We can retrieve a specific block s attribute data just by referring to the block name. Also, the keys themselves are used to populate a dialog box. This is why a scripting dictionary was chosen. 13

15 Obviously, this key cannot be duplicated. Therefore, we need to handle the error that will occur when we attempt to add a block that was already added. Code that you know will cause an error should be isolated in its own procedure so that you can handle the error with ease. In the case of all the error handlers for this project, we will use the On Error Resume Next statement. This causes the procedure to recognize the error but just continue with the next statement in the procedure. So the effect is that a new block is always added to the dictionary and an existing one is skipped (the error is ignored). Private Sub AddBlock(ByRef BlockStore As Scripting.Dictionary, _ ByVal Name As String, _ ByVal Attribs As Variant) On Error Resume Next BlockStore.Add Name, Attribs BlockDialog The first dialog needs to be constructed now. This dialog box will list all the block names and permit the user to select one. Insert a new form and name it BlockDialog. Change its caption to Select titleblock. Add a ListBox and name it BlockList. Resize the ListBox to a decent size. Add two CommandButtons. Name one DoOK and the other DoCancel. A module-level public variable is provided to communicate the user s choice of block back to the main code. Whenever a form is displayed, the UserForm_Activate event executes. Therefore, the list of blocks is cleared of any existing items. A variable is declared for an array that will come from the scripting dictionary. A scripting dictionary s Keys method returns the keys (in this case, the block names) as an array. This means that we do not need to perform any looping to populate the ListBox. A ListBox will accept an array to populate its list thru its List property. Finally, the two buttons properties are modified. Notice that the OK button is disabled whenever the form is displayed. It does not make sense to enable that button until the user selects a block. The BlockList_Click event enables the OK button. When the user hits Cancel, the module-level variable is cleared and the form is hidden. When the user hits OK, the module-level variable is set to the selected block name and the form is hidden. Option Explicit Public BlockPicked As String Private Sub UserForm_Activate() BlockList.Clear Dim blknames As Variant blknames = Main.AllBlocks.Keys BlockList.List = blknames DoOK.Accelerator = "O" DoOK.Caption = "OK" DoOK.Default = True DoOK.Enabled = False To array or not array Please note that the blknames array is not really necessary. The array from AllBlocks can be used directly by the List property and the array is not used elsewhere in this procedure. However, an array was declared so you could see what the data looks like when stepping thru the code. 14

16 DoCancel.Accelerator = "C" DoCancel.Caption = "Cancel" DoCancel.Cancel = True Private Sub BlockList_Click() DoOK.Enabled = True Private Sub DoCancel_Click() BlockPicked = "" Me.Hide Private Sub DoOK_Click() BlockPicked = BlockList.Value Me.Hide AttribDialog The dialog box to display the attributes and their values is very similar to the BlockDialog form. Insert a new form and name it AttribDialog. Change its caption to Select attribute to change. Add a ListBox and name it AttribList. Resize the ListBox to a decent size. Add two CommandButtons. Name one DoOK and the other DoCancel. A module-level public variable is provided to communicate the user s choice of attribute back to the main code as an AttributeReference object. The UserForm_Activate event clears the list of attributes of any existing items. The ListBox will actually use two columns to display the attribute data. The first column will display the attribute s tagname and the second column will display its value. The first column will be used to return the tagname when the OK button is selected. This is the BoundColumn property. The two columns get their widths assigned. A variable is declared for an array. It is created from data in the AllAttribs variable from the Main module. The array has two dimensions. The first dimension matches the count of the attributes. The second dimension stores the TagString (tagname) and the TextString (value) properties of the attribute. The ListBox is populated by its List property. Finally, the two buttons properties are modified just like the ones from BlockDialog. The rest of the procedures are just like the ones from BlockDialog, except that the global variable works with an object and not a string value. Option Explicit Public AttribPicked As AcadAttributeReference Private Sub UserForm_Activate() AttribList.Clear AttribList.BoundColumn = 1 AttribList.ColumnCount = 2 AttribList.ColumnWidths = "72;144" Dim attdata As Variant ReDim attdata(0 To UBound(Main.AllAttribs), 0 To 1) As String 15

17 Dim i As Long For i = 0 To UBound(Main.AllAttribs) attdata(i, 0) = Main.AllAttribs(i).TagString attdata(i, 1) = Main.AllAttribs(i).TextString Next i AttribList.List = attdata DoOK.Accelerator = "O" DoOK.Caption = "OK" DoOK.Default = True DoOK.Enabled = False DoCancel.Accelerator = "C" DoCancel.Caption = "Cancel" DoCancel.Cancel = True Private Sub AttribList_Click() DoOK.Enabled = True Private Sub DoCancel_Click() Set AttribPicked = Nothing Me.Hide Private Sub DoOK_Click() Set AttribPicked = Main.AllAttribs(AttribList.ListIndex) Me.Hide TextDialog Insert a new form and name it TextDialog. Change its caption to New value. Add a TextBox and name it Text. Resize it to a decent size. Add two CommandButtons. Name one DoOK and the other DoCancel. Two module-level public variables are supplied. DoUpdate is a true/false flag that communicates back to the main code whether or not the user selected the OK button. We cannot rely on the NewText variable to determine if we should proceed with the update because the user may want to blank the value, or force the current value on all the selected drawings. The TextBox is populated with the value from the attribute, and the text is selected, so the user can overwrite the text without manually selecting it. Finally, the two buttons properties are modified just like the ones from BlockDialog, except that the OK button is not disabled. The DoCancel_Click event forces the flag to false and hides the dialog box. The DoOK_Click event places the text from the TextBox in the NewText public variable, sets the flag to true, and hides the dialog box. Option Explicit Public DoUpdate As Boolean Public NewText As String 16

18 Private Sub UserForm_Activate() Text.SetFocus Text.Value = AttribDialog.AttribPicked.TextString Text.SelStart = 0 Text.SelLength = Len(Text.Value) DoOK.Accelerator = "O" DoOK.Caption = "OK" DoOK.Default = True DoCancel.Accelerator = "C" DoCancel.Caption = "Cancel" DoCancel.Cancel = True Private Sub DoCancel_Click() DoUpdate = False Me.Hide Private Sub DoOK_Click() NewText = Text.Value DoUpdate = True Me.Hide ProcessDrawings If all the data has been collected, then all the drawings are ready to be changed. The ProcessDrawings procedure will take four arguments. The array of drawing filenames The name of the selected block The tagname of the selected attribute The new text for the attributes There are two approaches to working with a drawing s specific objects. One you saw earlier, where the entire drawing, or specific layouts, are iterated thru, examining all objects for a match. This approach simplifies the code, and works fine for an expected large percentage of positive matches. The second approach, using a filtered selection set, is better when working in a drawing with a relatively small number of potential matches. This procedure will use a filtered selection set, as the code needs to work on only one specific block name, although there may be any number of insertions of that block. This also gives you the chance to see how to create a selection set and provide a filter for it. A selection set filter requires two arrays, one for the DXF-style codes and one for the filter data. The DXF-style codes array needs to be declared as using Integers, not Variants or Longs. The filter data can be of various data types, so its array needs to be declared as using Variants. The size of both arrays must match the number of filters you plan on using. Remember, arrays use a 0-based index. The DXF-style codes are found in the DXF Reference help files. Notice in the sample code that the index 0 data for both arrays is on the same line. Populating the arrays with the needed data is best done by grouping the two needed statements together in this fashion. Therefore, there are two filters to be used for the selection set: filter for inserts (DXF-style code 0) and of a specific name (DXF-style code 2). Several variables are then declared. One is a variable to hold the name of an open drawing if one of the drawings in the list is already open. The next stores the actual Document object. A variable 17

19 for the selection set object is declared. A variable is declared to hold the array of attributes. Finally, a couple of counters are needed. A For Next loop is used to open each drawing in turn. An ancillary procedure (GetOpenFilename) is used to see if the drawing is already open. If it is open already, the Document object is set to the open drawing. Otherwise, the drawing is opened and the variable is set to that newly opened drawing. An ancillary procedure (GetSS) is used to return a selection set object to this procedure. The details of why a separate procedure is used will be discussed under the GetSS topic. The selection set is then populated using the filters created earlier. The entire drawing is searched for matching objects. Notice the use of named arguments in the Select method. This method has two other optional arguments that occur before the filter arguments. Since those two arguments are not used, naming the arguments permits the statement to skip them. Another For Next loop is used to iterate thru all the objects in the selection set, changing the desired attribute s value in an ancillary procedure (ChangeAttrib). The selection set is then deleted. This is a good habit to get into. When a selection set is no longer needed, delete it. There are only 128 slots for selection sets. If you do not get in the habit of deleting unneeded selections sets in your code, you will discover programs failing during long editing sessions. Finally, the drawing is closed, saving the changes if the drawing was not read-only. The process then repeats on the next drawing. Private Sub ProcessDrawings(ByVal Dwgs As Variant, _ ByVal BlockName As String, _ ByVal TagName As String, _ ByVal NewText As String) Dim ftype(0 To 1) As Integer Dim fdata(0 To 1) As Variant ftype(0) = 0: fdata(0) = "INSERT" ftype(1) = 2: fdata(1) = BlockName Dim openfilename As String Dim mydwg As AcadDocument Dim myss As AcadSelectionSet Dim myatts As Variant Dim i As Long, j As Long For i = 0 To UBound(Dwgs) openfilename = GetOpenFilename(Dwgs(i)) If openfilename <> "" Then Set mydwg = AcadApplication.Documents.Item(openFilename) Else Set mydwg = AcadApplication.Documents.Open(Dwgs(i)) End If Set myss = GetSS(myDwg) myss.select Mode:=acSelectionSetAll, _ FilterType:=fType, _ FilterData:=fData For j = 0 To myss.count - 1 ChangeAttrib myss.item(j), TagName, NewText Next j myss.delete mydwg.close Not mydwg.readonly Next i 18

20 GetOpenFilename The main procedure, UpdateAttribute, opens the first drawing in the group selected by the user. There is no need to open the drawing again. In addition, any of the other drawings might be open in the AutoCAD session. So this procedure tests to see if a given drawing is open or not. The function needs one argument, the filename as found in the original array. Since the data type for those filenames in the array is a Variant, the argument here needs to be a Variant. The function will return just the filename and extension, without the path information. That is how each open document is stored in AutoCAD s Documents collection. A counter is declared, to be used by the For Next loop. Each open document s FullName property is compared to the given fully qualified filename from the calling procedure. If there is a match, the Name property is returned and the loop is exited. Notice the use of the With statement. This permits the code to use an object without storing it in a variable, while accessing several properties or methods of that object. In this case, both the FullName and Name properties are used within the With block of code. Private Function GetOpenFilename(fqnName As Variant) As String Dim i As Long For i = 0 To AcadApplication.Documents.Count - 1 With AcadApplication.Documents.Item(i) If StrComp(.FullName, fqnname, vbtextcompare) = 0 Then GetOpenFilename =.Name Exit For End If End With Next i End Function GetSS Creating a selection set in VBA is a bit tricky. The issue is that you cannot create a selection set without a name, and if a selection set with that name already exists, the attempt to create it will cause an error. Even worse, if you attempt to get a selection set with a name that does not exist, you will get an error. Therefore, an ancillary function to return a selection set object is needed, regardless of whether it exists or not. Remember, any code that you know can cause an error is best placed in its own procedure to isolate its error handling. This function requires one argument, the drawing for the selection set; and an optional argument for the name of the selection set. If the optional argument is not provided by the calling procedure, myss is used as the name. The function will return a SelectionSet object. The On Error Resume Next statement is used to recognize the error but just continue with the next statement in the procedure. An attempt is made to get an existing SelectionSet object of the given name. If this succeeds, the selection set is cleared of any existing objects. If the selection set did not exist, an error occurs on both statements. However, the error handler tells the procedure to continue with the next line of code. So the If statement checks to see if a specific error has occurred. If the error number equals 91, then the selection set does not exist. One is created then. In either case, the function returns an empty selection set, ready for use. 19

21 Private Function GetSS(ByRef thedoc As AcadDocument, _ Optional ByVal Name As String = "myss") _ As AcadSelectionSet On Error Resume Next Set GetSS = thedoc.selectionsets.item(name) GetSS.Clear 'Clear the selection set of any items If Err.Number = 91 Then Set GetSS = thedoc.selectionsets.add(name) End Function ChangeAttrib The final ancillary procedure for the sample application is the one that changes the attribute s value. This procedure requires three arguments: the inserted block, the attribute s tagname, and the new value for the attribute. An array is declared to hold the given block s attributes. The BlockReference object s GetAttributes method is used to populate that array. A counter is needed for the For Next loop used to go thru all the attributes found for the inserted block. When the matching attribute is found, the new value is placed in the TextString property and the loop is exited. Private Sub ChangeAttrib(ByVal theblock As AcadBlockReference, _ ByVal TagName As String, _ ByVal NewText As String) Dim myatts As Variant myatts = theblock.getattributes Dim i As Long For i = 0 To UBound(myAtts) With myatts(i) If.TagString = TagName Then.TextString = NewText Exit For End If End With Next i Conclusion The ABC s of VBA has given you a good start on learning how to automate AutoCAD using VBA. You see the advantages of writing programs in the VBAIDE. You have learned the basics of VBA syntax. As you can see, creating forms is very simple. AutoCAD s object model is explained and you know where to go for more information. Moreover, it is all wrapped up in a working application that allows you to edit multiple drawings. 20

22

Tools for the VBA User

Tools for the VBA User 11/30/2005-3:00 pm - 4:30 pm Room:Mockingbird 1/2 [Lab] (Swan) Walt Disney World Swan and Dolphin Resort Orlando, Florida R. Robert Bell - MW Consulting Engineers and Phil Kreiker (Assistant); Darren Young

More information

BasicScript 2.25 User s Guide. May 29, 1996

BasicScript 2.25 User s Guide. May 29, 1996 BasicScript 2.25 User s Guide May 29, 1996 Information in this document is subject to change without notice. No part of this document may be reproduced or transmitted in any form or by any means, electronic

More information

Mastering the Visual LISP Integrated Development Environment

Mastering the Visual LISP Integrated Development Environment Mastering the Visual LISP Integrated Development Environment R. Robert Bell Sparling SD7297 How do you create and edit your AutoLISP programming language software code? Are you using a text editor such

More information

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface CHAPTER 1 Finding Your Way in the Inventor Interface COPYRIGHTED MATERIAL Understanding Inventor s interface behavior Opening existing files Creating new files Modifying the look and feel of Inventor Managing

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

After completing this appendix, you will be able to:

After completing this appendix, you will be able to: 1418835463_AppendixA.qxd 5/22/06 02:31 PM Page 879 A P P E N D I X A A DEBUGGING After completing this appendix, you will be able to: Describe the types of programming errors Trace statement execution

More information

Copyrighted Material. Copyrighted. Material. Copyrighted

Copyrighted Material. Copyrighted. Material. Copyrighted Properties Basic Properties User Forms Arrays Working with Assemblies Selection Manager Verification and Error Handling Introduction This exercise is designed to go through the process of changing document

More information

VBScript: Math Functions

VBScript: Math Functions C h a p t e r 3 VBScript: Math Functions In this chapter, you will learn how to use the following VBScript functions to World Class standards: 1. Writing Math Equations in VBScripts 2. Beginning a New

More information

Las Vegas, Nevada, December 3 6, Kevin Vandecar. Speaker Name:

Las Vegas, Nevada, December 3 6, Kevin Vandecar. Speaker Name: Las Vegas, Nevada, December 3 6, 2002 Speaker Name: Kevin Vandecar Course Title: Introduction to Visual Basic Course ID: CP11-3 Session Overview: Introduction to Visual Basic programming is a beginning

More information

HOUR 4 Understanding Events

HOUR 4 Understanding Events HOUR 4 Understanding Events It s fairly easy to produce an attractive interface for an application using Visual Basic.NET s integrated design tools. You can create beautiful forms that have buttons to

More information

What to Do with the New CUI

What to Do with the New CUI 11/28/2005-8:00 am - 9:30 am Room:N. Hemispheres (Salon B/C) (Dolphin) Walt Disney World Swan and Dolphin Resort Orlando, Florida What to Do with the New CUI R. Robert Bell - MW Consulting Engineers CP11-1

More information

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide PROGRAMMING WITH REFLECTION: VISUAL BASIC USER GUIDE WINDOWS XP WINDOWS 2000 WINDOWS SERVER 2003 WINDOWS 2000 SERVER WINDOWS TERMINAL SERVER CITRIX METAFRAME CITRIX METRAFRAME XP ENGLISH Copyright 1994-2006

More information

VBA: Hands-On Introduction to VBA Programming

VBA: Hands-On Introduction to VBA Programming 11/28/2005-10:00 am - 11:30 am Room:Osprey 1 [Lab] (Swan) Walt Disney World Swan and Dolphin Resort Orlando, Florida VBA: Hands-On Introduction to VBA Programming Jerry Winters - VB CAD and Phil Kreiker

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

d2vbaref.doc Page 1 of 22 05/11/02 14:21

d2vbaref.doc Page 1 of 22 05/11/02 14:21 Database Design 2 1. VBA or Macros?... 2 1.1 Advantages of VBA:... 2 1.2 When to use macros... 3 1.3 From here...... 3 2. A simple event procedure... 4 2.1 The code explained... 4 2.2 How does the error

More information

SolidWorks A Visual Basic for Applications tutorial for SolidWorks users SDC PUBLICATIONS

SolidWorks A Visual Basic for Applications tutorial for SolidWorks users SDC PUBLICATIONS Automating SolidWorks 2004 using Macros A Visual Basic for Applications tutorial for SolidWorks users SDC PUBLICATIONS Schroff Development Corporation www.schroff.com www.schroff-europe.com By Mike Spens

More information

A Back-End Link Checker for Your Access Database

A Back-End Link Checker for Your Access Database A Back-End for Your Access Database Published: 30 September 2018 Author: Martin Green Screenshots: Access 2016, Windows 10 For Access Versions: 2007, 2010, 2013, 2016 Working with Split Databases When

More information

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

EXCEL 2003 DISCLAIMER:

EXCEL 2003 DISCLAIMER: EXCEL 2003 DISCLAIMER: This reference guide is meant for experienced Microsoft Excel users. It provides a list of quick tips and shortcuts for familiar features. This guide does NOT replace training or

More information

Chapter Eight: Editing a Part Program

Chapter Eight: Editing a Part Program Chapter Eight: Editing a Part Program Introduction PC-DMIS's main purposes are to allow you to create, edit, and execute part programs with ease. This chapter discusses using the Edit menu (with other

More information

Advanced Financial Modeling Macros. EduPristine

Advanced Financial Modeling Macros. EduPristine Advanced Financial Modeling Macros EduPristine www.edupristine.com/ca Agenda Introduction to Macros & Advanced Application Building in Excel Introduction and context Key Concepts in Macros Macros as recorded

More information

Creating a Dynamo with VBA Scripts

Creating a Dynamo with VBA Scripts Creating a Dynamo with VBA Scripts Creating a Dynamo with VBA 1 Table of Contents 1. CREATING A DYNAMO WITH VBA... 3 1.1 NAMING CONVENTIONS FOR DYNAMO OBJECTS...3 1.2 CREATING A DYNAMO...4 1.3 DESIGNING

More information

Microsoft Excel Level 2

Microsoft Excel Level 2 Microsoft Excel Level 2 Table of Contents Chapter 1 Working with Excel Templates... 5 What is a Template?... 5 I. Opening a Template... 5 II. Using a Template... 5 III. Creating a Template... 6 Chapter

More information

VBA Foundations, Part 12

VBA Foundations, Part 12 As quickly as you can Snatch the Pebble from my hand, he had said as he extended his hand toward you. You reached for the pebble but you opened it only to find that it was indeed still empty. Looking down

More information

Getting started 7. Writing macros 23

Getting started 7. Writing macros 23 Contents 1 2 3 Getting started 7 Introducing Excel VBA 8 Recording a macro 10 Viewing macro code 12 Testing a macro 14 Editing macro code 15 Referencing relatives 16 Saving macros 18 Trusting macros 20

More information

Tech-Talk Using the PATROL Agent COM Server August 1999 Authored By: Eric Anderson

Tech-Talk Using the PATROL Agent COM Server August 1999 Authored By: Eric Anderson Tech-Talk Using the PATROL Agent COM Server August 1999 Authored By: Eric Anderson Introduction Among the many new features of PATROL version 3.3, is support for Microsoft s Component Object Model (COM).

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

You will have mastered the material in this chapter when you can:

You will have mastered the material in this chapter when you can: CHAPTER 6 Loop Structures OBJECTIVES You will have mastered the material in this chapter when you can: Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand

More information

VBA Foundations, Part 11

VBA Foundations, Part 11 Welcome back for another look at VBA Foundations for AutoCAD. This issue will look at the concept of Events in greater depth. I mentioned in the last issue that events are at the heart of VBA and the AutoCAD

More information

Copyright (c) by Matthew S. Harris

Copyright (c) by Matthew S. Harris Documentation & How-To Didjiman's Forms Instance Manager Class For MS Access 2007 and Higher Version v2017-03-28 Copyright (c) 2014-2017 by Matthew S. Harris Permission is granted to copy, distribute and/or

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and VBA AND MACROS VBA is a major division of the stand-alone Visual Basic programming language. It is integrated into Microsoft Office applications. It is the macro language of Microsoft Office Suite. Previously

More information

Drawing an Integrated Circuit Chip

Drawing an Integrated Circuit Chip Appendix C Drawing an Integrated Circuit Chip In this chapter, you will learn how to use the following VBA functions to World Class standards: Beginning a New Visual Basic Application Opening the Visual

More information

Programming with the Peltier Tech Utility

Programming with the Peltier Tech Utility Programming with the Peltier Tech Utility The Peltier Tech Utility was designed so that much of its functionality is available via VBA as well as through the Excel user interface. This document explains

More information

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs 2 TUTORIAL This chapter contains the following topics. Overview on page 2-1 Exercise One: Building and Running a C Program on page 2-3 Exercise Two: Calling an Assembly Routine and Creating an LDF on page

More information

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace C++ Style Guide 1.0 General The purpose of the style guide is not to restrict your programming, but rather to establish a consistent format for your programs. This will help you debug and maintain your

More information

Debugging Code in Access 2002

Debugging Code in Access 2002 0672321025 AppA 10/24/01 3:53 PM Page 1 Debugging Code in Access 2002 APPENDIX A IN THIS APPENDIX Setting the Correct Module Options for Maximum Debugging Power 2 Using the Immediate Window 6 Stopping

More information

Managing Content with AutoCAD DesignCenter

Managing Content with AutoCAD DesignCenter Managing Content with AutoCAD DesignCenter In This Chapter 14 This chapter introduces AutoCAD DesignCenter. You can now locate and organize drawing data and insert blocks, layers, external references,

More information

Course Title: Mastering the Visual LISP Integrated Development Environment (IDE)

Course Title: Mastering the Visual LISP Integrated Development Environment (IDE) Las Vegas, Nevada, December 3 6, 2002 Speaker Name: R. Robert Bell Course Title: Mastering the Visual LISP Integrated Development Environment (IDE) Course ID: CP42-1 Course Outline: The introduction of

More information

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server Chapter 3 SQL Server Management Studio In This Chapter c Introduction to SQL Server Management Studio c Using SQL Server Management Studio with the Database Engine c Authoring Activities Using SQL Server

More information

Language Fundamentals

Language Fundamentals Language Fundamentals VBA Concepts Sept. 2013 CEE 3804 Faculty Language Fundamentals 1. Statements 2. Data Types 3. Variables and Constants 4. Functions 5. Subroutines Data Types 1. Numeric Integer Long

More information

The Basics of Visual Studio Code

The Basics of Visual Studio Code / VS Code 0.9.1 is available. Check out the new features /updates and update /docs/howtoupdate it now. TOPICS The Basics Tweet 16 Like 16 Edit in GitHub https://github.com/microsoft/vscode docs/blob/master/docs/editor/codebasics.md

More information

VBA Foundations, Part 7

VBA Foundations, Part 7 Welcome to this months edition of VBA Foundations in its new home as part of AUGIWorld. This document is the full version of the article that appears in the September/October issue of Augiworld magazine,

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #17. Loops: Break Statement

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #17. Loops: Break Statement Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #17 Loops: Break Statement (Refer Slide Time: 00:07) In this session we will see one more feature that is present

More information

6. Essential Spreadsheet Operations

6. Essential Spreadsheet Operations 6. Essential Spreadsheet Operations 6.1 Working with Worksheets When you open a new workbook in Excel, the workbook has a designated number of worksheets in it. You can specify how many sheets each new

More information

Outline. Debugging. In Class Exercise Solution. Review If Else If. Immediate Program Errors. Function Test Example

Outline. Debugging. In Class Exercise Solution. Review If Else If. Immediate Program Errors. Function Test Example Debugging Larry Caretto Mechanical Engineering 209 Computer Programming for Mechanical Engineers February 16, 2017 Outline Review choice statements Finding and correcting program errors Debugging toolbar

More information

How to Create a For Next Loop in Excel VBA!

How to Create a For Next Loop in Excel VBA! Often when writing VBA code, one may need to repeat the same action or series of actions more than a couple of times. One could, in this case, write each action over and over in one s code or alternatively

More information

(Refer Slide Time: 01:12)

(Refer Slide Time: 01:12) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl

More information

KEYWORDS DDE GETOBJECT PATHNAME CLASS VB EDITOR WITHEVENTS HMI 1.0 TYPE LIBRARY HMI.TAG

KEYWORDS DDE GETOBJECT PATHNAME CLASS VB EDITOR WITHEVENTS HMI 1.0 TYPE LIBRARY HMI.TAG Document Number: IX_APP00113 File Name: SpreadsheetLinking.doc Date: January 22, 2003 Product: InteractX Designer Application Note Associated Project: GetObjectDemo KEYWORDS DDE GETOBJECT PATHNAME CLASS

More information

OpenForms360 Validation User Guide Notable Solutions Inc.

OpenForms360 Validation User Guide Notable Solutions Inc. OpenForms360 Validation User Guide 2011 Notable Solutions Inc. 1 T A B L E O F C O N T EN T S Introduction...5 What is OpenForms360 Validation?... 5 Using OpenForms360 Validation... 5 Features at a glance...

More information

Working with Mailbox Manager

Working with Mailbox Manager Working with Mailbox Manager A user guide for Mailbox Manager supporting the Message Storage Server component of the Avaya S3400 Message Server Mailbox Manager Version 5.0 February 2003 Copyright 2003

More information

CS 142 Style Guide Grading and Details

CS 142 Style Guide Grading and Details CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable

More information

This chapter is intended to take you through the basic steps of using the Visual Basic

This chapter is intended to take you through the basic steps of using the Visual Basic CHAPTER 1 The Basics This chapter is intended to take you through the basic steps of using the Visual Basic Editor window and writing a simple piece of VBA code. It will show you how to use the Visual

More information

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms Access Forms Masterclass 5 Create Dynamic Titles for Your Forms Published: 13 September 2018 Author: Martin Green Screenshots: Access 2016, Windows 10 For Access Versions: 2007, 2010, 2013, 2016 Add a

More information

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide VBA Visual Basic for Applications Learner Guide 1 Table of Contents SECTION 1 WORKING WITH MACROS...5 WORKING WITH MACROS...6 About Excel macros...6 Opening Excel (using Windows 7 or 10)...6 Recognizing

More information

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 GETTING STARTED PAGE 02 Prerequisites What You Will Learn MORE TASKS IN MICROSOFT EXCEL PAGE 03 Cutting, Copying, and Pasting Data Basic Formulas Filling Data

More information

The name of this type library is LabelManager2 with the TK Labeling Interface reference.

The name of this type library is LabelManager2 with the TK Labeling Interface reference. Page 1 of 10 What is an ActiveX object? ActiveX objects support the COM (Component Object Model) - Microsoft technology. An ActiveX component is an application or library that is able to create one or

More information

INTRODUCTION... 1 UNDERSTANDING CELLS... 2 CELL CONTENT... 4

INTRODUCTION... 1 UNDERSTANDING CELLS... 2 CELL CONTENT... 4 Introduction to Microsoft Excel 2016 INTRODUCTION... 1 The Excel 2016 Environment... 1 Worksheet Views... 2 UNDERSTANDING CELLS... 2 Select a Cell Range... 3 CELL CONTENT... 4 Enter and Edit Data... 4

More information

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software. Welcome to Basic Excel, presented by STEM Gateway as part of the Essential Academic Skills Enhancement, or EASE, workshop series. Before we begin, I want to make sure we are clear that this is by no means

More information

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION Lesson 1 - Recording Macros Excel 2000: Level 5 (VBA Programming) Student Edition LESSON 1 - RECORDING MACROS... 4 Working with Visual Basic Applications...

More information

Roxen Content Provider

Roxen Content Provider Roxen Content Provider Generation 3 Templates Purpose This workbook is designed to provide a training and reference tool for placing University of Alaska information on the World Wide Web (WWW) using the

More information

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4. Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations

More information

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows CHAPTER 1 Getting to Know AutoCAD Opening a new drawing Getting familiar with the AutoCAD and AutoCAD LT Graphics windows Modifying the display Displaying and arranging toolbars COPYRIGHTED MATERIAL 2

More information

BASIC Stamp Windows Interface (v1.1)

BASIC Stamp Windows Interface (v1.1) BASIC Stamp Windows Interface (v1.1) FEATURES: GENERAL: Win95/98/Me/NT 4.0/2000 compatible. This software runs under Windows 95 and 98 (both new and upgrade versions), as well as Windows NT 4.0 and Windows

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

2 The Stata user interface

2 The Stata user interface 2 The Stata user interface The windows This chapter introduces the core of Stata s interface: its main windows, its toolbar, its menus, and its dialogs. The five main windows are the Review, Results, Command,

More information

Using Visual Studio.NET: IntelliSense and Debugging

Using Visual Studio.NET: IntelliSense and Debugging DRAFT Simon St.Laurent 3/1/2005 2 Using Visual Studio.NET: IntelliSense and Debugging Since you're going to be stuck using Visual Studio.NET anyway, at least for this edition of the.net Compact Framework,

More information

MadCap Software. Index Guide. Flare 2017 r2

MadCap Software. Index Guide. Flare 2017 r2 MadCap Software Index Guide Flare 2017 r2 Copyright 2017 MadCap Software. All rights reserved. Information in this document is subject to change without notice. The software described in this document

More information

Getting started 7. Setting properties 23

Getting started 7. Setting properties 23 Contents 1 2 3 Getting started 7 Introducing Visual Basic 8 Installing Visual Studio 10 Exploring the IDE 12 Starting a new project 14 Adding a visual control 16 Adding functional code 18 Saving projects

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

AutoCAD Electrical Customization from A to Z

AutoCAD Electrical Customization from A to Z 11/30/2005-10:00 am - 11:30 am Room:Parrot 1/2 (Swan) Walt Disney World Swan and Dolphin Resort Orlando, Florida AutoCAD Electrical Customization from A to Z Randy Brunette - Brunette Technologies, LLC

More information

Programming Fundamentals

Programming Fundamentals Programming Fundamentals Computers are really very dumb machines -- they only do what they are told to do. Most computers perform their operations on a very primitive level. The basic operations of a computer

More information

SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7

SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7 SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7 Hi everyone once again welcome to this lecture we are actually the course is Linux programming and scripting we have been talking about the Perl, Perl

More information

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35 Contents Modify the Project 30 Introduction to Print the Project Documentation 35 Visual Basic 1 Sample Printout 36 Writing Windows Applications The Form Image 36 The Code 37 with Visual Basic 2 The Form

More information

PowerPoint Essentials

PowerPoint Essentials Lesson 1 Page 1 PowerPoint Essentials Lesson Skill Matrix Skill Exam Objective Objective Working with an Existing Change views of a Insert text on a slide. 1.5.2 2.1.1 Software Orientation Normal View

More information

3 TUTORIAL. In This Chapter. Figure 1-0. Table 1-0. Listing 1-0.

3 TUTORIAL. In This Chapter. Figure 1-0. Table 1-0. Listing 1-0. 3 TUTORIAL Figure 1-0. Table 1-0. Listing 1-0. In This Chapter This chapter contains the following topics: Overview on page 3-2 Exercise One: Building and Running a C Program on page 3-4 Exercise Two:

More information

END-TERM EXAMINATION

END-TERM EXAMINATION (Please Write your Exam Roll No. immediately) END-TERM EXAMINATION DECEMBER 2006 Exam. Roll No... Exam Series code: 100274DEC06200274 Paper Code : MCA-207 Subject: Front End Design Tools Time: 3 Hours

More information

COPYRIGHTED MATERIAL. Part I: Getting Started. Chapter 1: IDE. Chapter 2: Controls in General. Chapter 3: Program and Module Structure

COPYRIGHTED MATERIAL. Part I: Getting Started. Chapter 1: IDE. Chapter 2: Controls in General. Chapter 3: Program and Module Structure Part I: Getting Started Chapter 1: IDE Chapter 2: Controls in General Chapter 3: Program and Module Structure Chapter 4: Data Types, Variables, and Constants Chapter 5: Operators Chapter 6: Subroutines

More information

Excel VBA Variables, Data Types & Constant

Excel VBA Variables, Data Types & Constant Excel VBA Variables, Data Types & Constant Variables are used in almost all computer program and VBA is no different. It's a good practice to declare a variable at the beginning of the procedure. It is

More information

Tracking changes in Word 2007 Table of Contents

Tracking changes in Word 2007 Table of Contents Tracking changes in Word 2007 Table of Contents TRACK CHANGES: OVERVIEW... 2 UNDERSTANDING THE TRACK CHANGES FEATURE... 2 HOW DID THOSE TRACKED CHANGES AND COMMENTS GET THERE?... 2 WHY MICROSOFT OFFICE

More information

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Visual Basic.NET. 1. Which language is not a true object-oriented programming language? Visual Basic.NET Objective Type Questions 1. Which language is not a true object-oriented programming language? a.) VB.NET b.) VB 6 c.) C++ d.) Java Answer: b 2. A GUI: a.) uses buttons, menus, and icons.

More information

1. Introduction to Microsoft Excel

1. Introduction to Microsoft Excel 1. Introduction to Microsoft Excel A spreadsheet is an online version of an accountant's worksheet, which can automatically do most of the calculating for you. You can do budgets, analyze data, or generate

More information

Clickteam Fusion 2.5 Creating a Debug System - Guide

Clickteam Fusion 2.5 Creating a Debug System - Guide INTRODUCTION In this guide, we will look at how to create your own 'debug' system in Fusion 2.5. Sometimes when you're developing and testing a game, you want to see some of the real-time values of certain

More information

Azon Master Class. By Ryan Stevenson Guidebook #7 Site Construction 2/3

Azon Master Class. By Ryan Stevenson   Guidebook #7 Site Construction 2/3 Azon Master Class By Ryan Stevenson https://ryanstevensonplugins.com/ Guidebook #7 Site Construction 2/3 Table of Contents 1. Creation of Site Pages 2. Category Pages Creation 3. Home Page Creation Creation

More information

Basic Concepts. Launching MultiAd Creator. To Create an Alias. file://c:\documents and Settings\Gary Horrie\Local Settings\Temp\~hh81F9.

Basic Concepts. Launching MultiAd Creator. To Create an Alias. file://c:\documents and Settings\Gary Horrie\Local Settings\Temp\~hh81F9. Page 1 of 71 This section describes several common tasks that you'll need to know in order to use Creator successfully. Examples include launching Creator and opening, saving and closing Creator documents.

More information

Getting started 7. Setting properties 23

Getting started 7. Setting properties 23 Contents 1 2 3 Getting started 7 Introduction 8 Installing Visual Basic 10 Exploring the IDE 12 Starting a new project 14 Adding a visual control 16 Adding functional code 18 Saving projects 20 Reopening

More information

Creating Web Pages with SeaMonkey Composer

Creating Web Pages with SeaMonkey Composer 1 of 26 6/13/2011 11:26 PM Creating Web Pages with SeaMonkey Composer SeaMonkey Composer lets you create your own web pages and publish them on the web. You don't have to know HTML to use Composer; it

More information

PowerPoint Essentials 1

PowerPoint Essentials 1 PowerPoint Essentials 1 LESSON SKILL MATRIX Skill Exam Objective Objective Number Working with an Existing Presentation Change views of a presentation. Insert text on a slide. 1.5.2 2.1.1 SOFTWARE ORIENTATION

More information

'... '... '... Developer: William H. White (consultant) '... With: TEKsystems Inc. '... For: AIG. Financial Information Systems

'... '... '... Developer: William H. White (consultant) '... With: TEKsystems Inc.   '... For: AIG. Financial Information Systems ThisWorkbook - 1 Developer: William H. White (consultant) With: TEKsystems Inc. www.teksystems.com For: AIG Financial Information Systems 1 NY Plaza, 15th floor Current contact: william.white@aig.com (212)

More information

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5. Page 1 of 5 6.170 Laboratory in Software Engineering Java Style Guide Contents: Overview Descriptive names Consistent indentation and spacing Informative comments Commenting code TODO comments 6.170 Javadocs

More information

Xton Access Manager GETTING STARTED GUIDE

Xton Access Manager GETTING STARTED GUIDE Xton Access Manager GETTING STARTED GUIDE XTON TECHNOLOGIES, LLC PHILADELPHIA Copyright 2017. Xton Technologies LLC. Contents Introduction... 2 Technical Support... 2 What is Xton Access Manager?... 3

More information

AutoCAD 2009 User InterfaceChapter1:

AutoCAD 2009 User InterfaceChapter1: AutoCAD 2009 User InterfaceChapter1: Chapter 1 The AutoCAD 2009 interface has been enhanced to make AutoCAD even easier to use, while making as much screen space available as possible. In this chapter,

More information

Visual basic tutorial problems, developed by Dr. Clement,

Visual basic tutorial problems, developed by Dr. Clement, EXCEL Visual Basic Tutorial Problems (Version January 20, 2009) Dr. Prabhakar Clement Arthur H. Feagin Distinguished Chair Professor Department of Civil Engineering, Auburn University Home page: http://www.eng.auburn.edu/users/clemept/

More information

Single Menus No other menus will follow necessitating additional user choices

Single Menus No other menus will follow necessitating additional user choices 57 UNIT-III STRUCTURES OF MENUS Single Menus No other menus will follow necessitating additional user choices Sequential Linear Menus Simultaneous Menus 58 Hierarchical Menus When many relationships exist

More information

Contents. Remote Control Playback Controls What s on TV? Using the OK Button Using the Info Button... 6

Contents. Remote Control Playback Controls What s on TV? Using the OK Button Using the Info Button... 6 Contents Remote Control... 4 Playback Controls.... 5 What s on TV?.... 6 Using the OK Button.... 6 Using the Info Button.... 6 Using the Browse Button.... 6 Using the Channel Guide... 7 ReStartTV... 8

More information

10 Implinks and Endpoints

10 Implinks and Endpoints Chapter 10 Implinks and Endpoints Implementation links and endpoints are important concepts in the SOMT method (described in the SOMT Methodology Guidelines starting in chapter 69 in the User s Manual).

More information

Making Your Label Styles Work For You in C3D

Making Your Label Styles Work For You in C3D Making Your Label Styles Work For You in C3D Mark Hultgren Smith Engineering CV110-5 Once you have completed this course, you'll understand and be able to apply the methods for developing a complete set

More information

Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures

Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures Microsoft Visual Basic 2005 CHAPTER 6 Loop Structures Objectives Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand the use of counters and accumulators Understand

More information

PC-Kits USER GUIDE. SOFTWARE SUPPORT Monday - Friday 8:00am - 4:00pm Pacific Time

PC-Kits USER GUIDE. SOFTWARE SUPPORT Monday - Friday 8:00am - 4:00pm Pacific Time PC-Kits USER GUIDE SOFTWARE SUPPORT Monday - Friday 8:00am - 4:00pm Pacific Time 1-800-356-0709 Copyright Visual Health Information. All rights reserved. CONTENTS STARTING VHI PC-KITS... 1 ACTIVATING VHI

More information

Creating a new form with check boxes, drop-down list boxes, and text box fill-ins. Customizing each of the three form fields.

Creating a new form with check boxes, drop-down list boxes, and text box fill-ins. Customizing each of the three form fields. In This Chapter Creating a new form with check boxes, drop-down list boxes, and text box fill-ins. Customizing each of the three form fields. Adding help text to any field to assist users as they fill

More information