Ad

Friday, December 14, 2007

VBA: Export to Excel and Then Some

On the 6-30-2007 date on this website I previously posted a VBA macro to get pipe and structure quantities from a drawing. This is an example of how to export information to Excel and then modify it. So lets say you thought it was neat, but wanted to change what it did in Excel and didn't have much VBA experience. An easy imageway to see what direction you should go in would be to use the macro recorder in Excel. To get to the macro recorder in pre-2007 its under Tools => Macro => Record Macro. In 2007 you will have to go to the Microsoft symbol and select Excel Options. Under popular, check the "Show Developer tab in the Ribbon".

In the Developer tab use the Record Macro button and press Ok when the Record Macro dialog box pops up. Excel will now keep a record of all of the movements and commands you do. Do what you want the routine you are creating to do. When you are done press the Stop Recording button (before 2007 it is on toolbar imagethat pops up when the recording starts, in 2007 it is on the Developer ribbon). Once you stop the recording choose the Visual Basic option to see the code that was created.

image

The code Excel created is in the next picture. It will take a little work to make AutoCAD do the commands in Excel, but the sample mentioned earlier should start you on your way or take a look at the AU class I did which has another example.

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad