Code:
Option Explicit'Modify following options to fit your needs
Const sFullExcelFileName As String = "C:\Pfad\Zeichnungsliste.xlsx" ' Name and Path to the excel file
Const sSheetName As String = "Zeichnungen" ' Name of the Excel sheet
Private Sub ImportExcelMaterials()
Dim oApp As Inventor.Application
Set oApp = ThisApplication
Dim oDrawDoc As DrawingDocument
Dim aDrawings() As Variant
aDrawings() = ReadXLSFileIntoArray(sFullExcelFileName)
Dim i As Integer
For i = 2 To UBound(aDrawings)
Call PrintDrawing(aDrawings(i, 1))
Next
End Sub
Private Function ReadXLSFileIntoArray(ByVal sFileName As String) As Variant()
Dim oExcelApp As New Excel.Application
oExcelApp.Visible = False 'Visible is False by default, so this isn't necessary
Dim oWB As Excel.Workbook
Dim oWS As Excel.WorkSheet
Set oWB = oExcelApp.Workbooks.Open(sFileName)
For Each oWS In oWB.Sheets
If oWS.Name = sSheetName Then Exit For
Next
ReadXLSFileIntoArray = oWS.UsedRange
oWB.Close (False)
oExcelApp.Quit
End Function
Private Sub PrintDrawing(ByVal sDrawing As String)
Dim oFS As New FileSystemObject
If oFS.FileExists(sDrawing) Then
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Open(sDrawing)
If ThisApplication.ActiveDocument.FullFileName = sDrawing Then
Call Print2PDF(oDrawDoc)
Call Print2DXF(oDrawDoc)
oDrawDoc.Close (True)
End If
End If
End Sub
Private Sub Print2PDF(ByVal oDrawDoc As DrawingDocument)
MsgBox ("Print2PDF " & oDrawDoc.FullFileName)
'TODO implement PDF Export
End Sub
Private Sub Print2DXF(ByVal oDrawDoc As DrawingDocument)
MsgBox ("Print2DXf " & oDrawDoc.FullFileName)
'TODO implement DXF Export
End Sub