If you would like to learn the language from the beginning you probably should purchase some books, cources. I believe there should be some on-line trainings for Visual Basic. But it will take some time.

If you need some brief skills for example to modify the recordered macro I would like to propose the following:

Once the macro recordered analize its code and refering to API Help Documentation identify which method for. Use F8 key to debug the macro step-by-step and you can see which line of code actually doing.

Macro usually writes some excess code (for example view rotation, selection etc) which can be removed from the macro. The step-by-step debuging would help to identify such lines.

Thanks for the quick reply. It definitely is a massive topic to understand and would take time to learn properly. But as I do not have that luxuary at the minute I am just trying to go for the basics.

I used the F8 command like you said (very useful indeed to see whats going on) and stripped out all the unnecessary code. Is there any quick way of say editing the coordinates so that if I knew the height of the line/part that I wanted it to be, I could enter it in somewhere in the code?

There is only one method in SOlidWorks for drawing the line: ModelDoc2::CreateLine2 which expects the coordinates of two end points. However you can create your custom function which will create a line by for example a start point and height.

But note that the start point and the length is not enought to define the line. The angle should be defined as well.

The sample of such function. (Note. The end point's coordinates should be calculated):

Not knowing how to program this is going to be a very hard thing to do. You can input all your values into a excel file and then import that. Look for design tables in the help, there are some great examples on the Internet so go do a search. if you have never worked with these it will be a learning curve but a lot shorter learning curve the trying to use VB to do this.

look through the help file for design tables. you should create your part and then create a configuration and modify any parameters that change for the configurations then use the auto-create option. This will give you an excel table that you can use to create all your part variations. Seriously review the help to get you going.

Take a look at the attached part. Click on the Configuration Manager tab at the top of the feature tree. In there, you should see a Design Table object.

If you right-click on this, you should be able to Edit Table in New Window. This will open an excel spreadsheet with all the dimensions of this part in the default configuration and the Config2 configuration. You can change the values in the spreadsheet, and the dimensions will change in the corresponding configurations. You can even copy a row and rename the first column of that row and create a new configuration with different dimensions. When you close the spreadsheet, SolidWorks will ask if you want to create new configurations for any rows you may have added.

This is a pretty cool feature.

If you have your own part and you want to do something similar, it will be easiest if you create at least 2 configurations and change the relevant dimensions in each configuration. When you change the dimensions notice that on the Modify form, there are a few icons under the dimension. The last one on the right allows you to specify where you want to change the dimension. If you don't select THIS CONFIGURATION, that dimension may change in all other configurations.

You should set a different value for each dimension that you want to vary (through the spreadsheet) in each configuration. For example, if you want to vary the Width, make sure you set the width to a different value in each configuration, etc.

Now you should be able to automatically create a design table. If you don't see the TABLE toolbar anywhere on your screen, you can right click on a blank area of your toolbar and check TABLE. You will see a new toolbar show up. If you click the second icon from the end of this toolbar, you will get the Design table dialog. You can just choose autocreate to get used to the idea.

They are really hard to use and require abundant brain power . Only the uber-intelligent should try them after first going through the easy method of writing a visual basic or C# application to do it manually (which, of course, is much easier)....

FYI, that method of reading/writing cells is pretty inefficient. Selecting cells in Excel will waste resources. Also, it is much easier to loop through Excel cells by number rather than by combination of letters and numbers.

'' write to A2excelapp.range("A2").Selectexcelapp.ActiveCell.FormulaR1C1 = "Write to a Cell"

is the same as

'' write to A2excelapp.ActiveWorkbook.Cells(2, 1).FormulaR1C1 = "Write to a Cell"

I do not find the 2009 API help very helpful if I do not understand the objects first, although it is nicer for looking up the methods. If a person has access to SW 2008 the help is friendlier especially for a person who has not worked with VB. In 2008 it is easier to find examples.To work with Excel you need to know how to work with Excel objects in addition to SolidWorks plus normal Visual Basic.

Have you looked into design tables? Sounds like what you want can be accomplished in a DT without need for macros.

Recorded macros are a mediocre beginning to understanding VB and SW API. Recorded macros tend to miss many important commands. The results are often unusable, especially when entity selection is involved. The convoluted method of recording can lead to a poorer understanding of how SW API is actually structured.