There was a recent question in the customization newsgroup about creating a parts list in Word or Excel that contained the thumbnail image for each part. This seemed like an interesting problem to tackle. Since a parts list is a table, Excel was the obvious first choice. However, after playing with it a bit I found that Excel doesn’t support inserting pictures into cells and from what I found online is an enhancement coming in Office 2010. I also found out that Word does allow you to insert pictures into table cells so that’s what I decided to use.
Below is an example of the result using one of the sample files that comes with Inventor.
My initial code for this was a VBA macro but it was found to have a problem on 64-bit machines. I’m leaving the original VBA version described below because it’s simpler and easier to understand the what’s going on. It isn’t fancy but mostly does the job. The new version is an add-in and will work on 32 and 64-bit machines.
Add-In Version
To use this version download this zip file. Inside the zip is a .exe and another zip file. The .exe is an installer and running it will install the add-in. It creates a new button on the Tools tab of the drawing ribbon. If you’re using the classic UI then it adds a new button to the annotation panel bar. The add-in is compatible with Inventor 2010. The zip file contains the source code for the add-in, in case you’re interested in that. It was written using Visual Basic Express 2008.
VBA Version
You can To use the program you need to copy and paste the source code into VBA. I would recommend pasting it into your VBA application project, as shown below.
Since this program uses Word and drives it through the Word API, you need to add a reference to the Word Object Library. You do this by using the References… command in the Tools menu within VBA. You need to check the box next to “Microsoft Word 12.0 Object Library” as shown below. (I received some feedback on the newsgroup that this will also work with Word 2002 with some small changes to the code, which I’ve made the linked source code. There’s also a change so that it’s tolerant of files that don’t have a thumbnail. Thanks to Cadfish1 from the autodesk.inventor.customization newsgroup for his input.)
Now you’re all set. You need to have a drawing open and the parts list selected that you want to write out and then you can run the program. You run the program using the Macros command on the Tools tab of Inventor (which you can also access using Alt-F8). Once it’s finished you should have a new Word document that contains the parts list table.