excel and inventor

excel and inventor

GosponZ
Collaborator Collaborator
731 Views
4 Replies
Message 1 of 5

excel and inventor

GosponZ
Collaborator
Collaborator

I'm trying to export few iProperties into Excel but on this line shows me error


SyntaxEditor Code Snippet

Dim Names={"Display name", "Title", "Part Number", "Date", "Revision"}

Array initializers are valid only for arrays, but the type of 'Names' is 'Object'

Can you guys guide me in right direction, please.

'Try the following rule to debug the export of your iProperties to the Excel workbook. 
'It assumes that the active document is an assembly

'open the existing excel file
GoExcel.Open("c:\TEMP\EXPORT.xlsx", "Sheet1")

'Print column titles in the row 2
Dim Names={"Display name", "Title", "Part Number", "Date", "Revision"}
GoExcel.CellValues("A2", "E2") = Names

Dim oAsmDoc As AssemblyDocument = TryCast(ThisApplication.ActiveDocument,AssemblyDocument)
If oAsmDoc Is Nothing Then
	MessageBox.Show("Activate assembly document first", "iLogic",MessageBoxButtons.OK,MessageBoxIcon.Information)
	Exit Sub
End If

Dim Data(4) As String	'string array for properties	
Dim row As Integer = 3	'start data row
Dim oPropSet As PropertySet
Dim oProp As Inventor.Property	

For Each oDoc As Inventor.Document In oAsmDoc.AllReferencedDocuments
	'full filename
	Data(0) = oDoc.FullFileName

    'Title
    oPropSet = oDoc.PropertySets.Item("Inventor Summary Information")
    oProp = oPropSet.Item("Title")
	Data(1) = oProp.Value
    
    'Part Number
    oPropSet = oDoc.PropertySets.Item("Design Tracking Properties")
    oProp = oPropSet.Item("Part Number")
	Data(2) = oProp.Value
    
    'Date
    oPropSet = oDoc.PropertySets.Item("Design Tracking Properties")
    oProp = oPropSet.Item("Creation Time")
	Data(3) = oProp.Value
    
    'Revision
    oPropSet = oDoc.PropertySets.Item("Inventor Summary Information")
    oProp = oPropSet.Item("Revision Number")
	Data(4) = oProp.Value
    
	GoExcel.CellValues("A" & CStr(row), "E" & CStr(row)) = Data
	row += 1
Next

GoExcel.Save
GoExcel.Close
    
MessageBox.Show("Done", "iLogic",MessageBoxButtons.OK,MessageBoxIcon.Information)

 

Here is whole code i found i beleive in this forum. Thanks for help

 

0 Likes
Accepted solutions (1)
732 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution
Dim Names(4) as string
Names = {"Display name", "Title", "Part Number", "Date", "Revision"}

 

Message 3 of 5

GosponZ
Collaborator
Collaborator

Thanks

0 Likes
Message 4 of 5

GosponZ
Collaborator
Collaborator

When i try on Inventor 2015 it is working very well and i acepted as solution, but with  Iv2012 do have problem

LIne 6: Expression expected

 

Names = {"Display name", "Title", "Part Number", "Date", "Revision"}

 what is difference?

Thank you for any advice

0 Likes
Message 5 of 5

GosponZ
Collaborator
Collaborator

It is just wierd, any advice?

0 Likes