Hi All,
I'm trying to write my first VBA program for Inventor with very little programming experience. I would like to create a userform which displays the materials list within a combobox.
The problem I have is that I would like the userform to remain open no matter which type of file is active. I would like the combobox to displayi the material list and current material when in a Part file and display N/A when in Assembly file.
I figure it would probably be an if statement, but I don't know how to configure it.
Any help would be gratefully appreciated.
Thanks,
Graeme
Inventor 2011 pro
Windows XP Pro 64 SP2
Solved! Go to Solution.
Solved by xiaoyan.qi. Go to Solution.
HI, Graeme
Here is a Simple VBA code to use if statement for different operation between Part & Assembly
==================================================
Sub SimpleCase()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc.DocumentType = kPartDocumentObject Then
' the statement for Part
ElseIf oDoc.DocumentType = kAssemblyDocumentObject Then
' the statement for Assembly
End If
End Sub
==================================================
let me know if it works for you
Thanks
Mick
Hi Mick,
Thanks for the reply, It worked just as I hoped. Now that the coding is complete, I would like to make it an Inventor add-in. The problem is I'm not sure how to achieve this.
I'm using visual basic 2010 express, I was following Brian Ekins tutorial "taking the step from VBA to Inventor Add-ins" but when I try to debug the project, I get the following message
"A project with an output type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the libary project. Set the executable project as the startup project."
I have searched the Internet for solutions, but the only ones I can find are for use with Visual Studio.
Any suggestions?
in Visual studio, Menu Tools-> Attach to Process, select Inventor Application.
then in Inventor, Load the add-in, work on your Add-in command, if there is error, add breakpoint on the statement to debug it.
Hope it's helpful
Thanks
Mick