Excel VBA Quotation tool to open, refresh, print, and save/saveas Autodesk Inventor 2011 files

Posted on 2011-03-08
Medium Priority
Last Modified: 2012-05-11
We have a quotation tool that runs some file save and folder generations I would like to add a routine to convert the "Quote" to a project and link it to the Ilogic rouitines I have generated in Autodesk inventor 2011. The Ilogic is triggered by a file open / save. Phase one is to produce sales and shop drawings with the ilogic tool set then triger these tools from excel as the project folders are generated. I would like to trigger this from the excel quotation tool as a macro if possible. quote tool uses outlook to send email:

Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)

is there a similar command for Autodesk Inventor?

I am self taught as a programer and would much appreciate any help i can get on the VBA side. I am very skilled in inventor and will handel the ilogic side interenally.

Thank You

Question by:ctowers
  • 3
  • 2
LVL 12

Expert Comment

ID: 35072722
Autodesk is moving from VBA to VB.NET programming language, the developer's guide for .NET can be found here:

If you wish to continue with VBA within AutoCAD 2010 or 2011 products you need to install module found here:

Here is some sample code from the .NET Developer's Guide i previously linked:

Open an existing AutoCAD Drawing:
Imports System.IO
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
<CommandMethod("OpenDrawing", CommandFlags.Session)> _
Public Sub OpenDrawing()
  Dim strFileName As String = "C:\campus.dwg"
  Dim acDocMgr As DocumentCollection = Application.DocumentManager
  If (File.Exists(strFileName)) Then
      acDocMgr.Open(strFileName, False)
      acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " & strFileName & _
                                                     " does not exist.")
  End If
End Sub

Open in new window

Save the AutoCAD Drawing:
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
<CommandMethod("SaveActiveDrawing")> _
Public Sub SaveActiveDrawing()
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim strDWGName As String = acDoc.Name
  Dim obj As Object = Application.GetSystemVariable("DWGTITLED")
  '' Check to see if the drawing has been named
  If System.Convert.ToInt16(obj) = 0 Then
      '' If the drawing is using a default name (Drawing1, Drawing2, etc)
      '' then provide a new name
      strDWGName = "c:\MyDrawing.dwg"
  End If
  '' Save the active drawing
  acDoc.Database.SaveAs(strDWGName, True, DwgVersion.Current, _
End Sub

Open in new window


Author Comment

ID: 35076790

Thank you for your response. Will the code above work with Autodesk Inventor files or is it only "Autocad" specific?

LVL 12

Accepted Solution

silverkorn earned 2000 total points
ID: 35082389
That sample code should work with all instances of AutoCAD since they all share the common commands of open/save/close. When you get into Inventor specific tasks is when the code will not translate back to standard AutoCAD

Here is a great webinar series about programming with AutoCAD Inventor:
LVL 12

Expert Comment

ID: 35082438

Author Closing Comment

ID: 35096629
Thank you for all your help and the direction. I was on the road with my tablet and couldn't see the video but got back yesterday and spent some time on it last night. It will help alot thanks.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question