Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
mraymond7REU2
in reply to: fullevent

I solved this a while ago and forgot to come back here to post my findings. Below is the code that I put together which has the added benefit of exporting to csv instead of excel so excel doesn't need to be installed on the machine and it prompts for the files to be exported and the csv file to export them to.

 

 

Imports System.IO
' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
oApplication = GetObject(, "Inventor.Application")

' FOLDER selection dialog
Dim FilePATH As String = "FilePATH"
Dim dialog As New System.Windows.Forms.FolderBrowserDialog()
dialog.SelectedPath = "R:\Drawings"
dialog.Description = "Select Folder to Pull Drawing Properties From (recursive)"
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
	drawingDir = dialog.SelectedPath
Else
	MsgBox("canceled!")
End If

' FILE Selection dialog
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End If


'Dim drawingDir = "R:\Drawings"
For Each foundFile As String In My.Computer.FileSystem.GetFiles(drawingDir, FileIO.SearchOption.SearchAllSubDirectories, "*.idw")
	ThisDoc.Launch(foundFile)
	
	' Set a reference to the active document.
	' This assumes a document is open.
	Dim oDoc As Document
	oDoc = oApplication.ActiveDocument
	      
	' Obtain the PropertySets collection object
	Dim oPropsets As PropertySets
	oPropsets = oDoc.PropertySets
	
	PartNo = oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kPartNumberDesignTrackingProperties).Value
	Revision = oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kRevisionSummaryInformation).Value
	Description = oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDescriptionDesignTrackingProperties).Value

	'Write data info To CSV File
	Dim oAppend As System.IO.StreamWriter
	'selectedfile = "C:\Users\mraymond\Documents\drawings-local\test\inv-master.csv"
	oAppend = IO.File.AppendText(selectedfile)
	oAppend.WriteLine(PartNo & "," & Revision & "," & Chr(34) & Description & Chr(34))
	oAppend.Flush()
	oAppend.Close()
	
	ThisApplication.Documents.CloseAll()
	
Next