Loading data from the .xlsx table into the table

Loading data from the .xlsx table into the table

ProRuzneDrobnosti
Contributor Contributor
193 Views
2 Replies
Message 1 of 3

Loading data from the .xlsx table into the table

ProRuzneDrobnosti
Contributor
Contributor

Hello everyone, is it possible to modify this code (received from FINET_Laurent) so that the data is written to an table (General ProRuzneDrobnosti_0-1708596529886.pngon the Inventor drawing page. Not in Titleblock

Thank you very much for your reply

 

 

 

Sub main
	Dim excelTable As Dictionary(Of String, String) = get_inputs
	
	Dim doc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
	Dim titleblock As Inventor.TitleBlock = doc.ActiveSheet.TitleBlock
	Dim s As Inventor.DrawingSketch = titleblock.Definition.Sketch
	
	For Each t As Inventor.TextBox In s.TextBoxes
			For Each k As String In excelTable.Keys
				If t.Text = "<" & k & ">" Then
					titleblock.SetPromptResultText(t, excelTable(k))
					Exit For
					
				End If
			Next
	Next
	
End Sub

Function get_inputs() As Dictionary(Of String, String)
	Dim propertiesColumn As String = "A"
	Dim valuesColumn As String = "B"
	Dim firstLine As Integer = 1
	Dim lastLine As Integer = 3
	
	Dim excelTable As New Dictionary(Of String, String)

	For i As Byte = firstLine To lastLine
		Dim p As String = GoExcel.CellValue("TitleBlock.xlsx", "Tabelle1", propertiesColumn & i)
		Dim v As String = GoExcel.CellValue("TitleBlock.xlsx", "Tabelle1", valuesColumn & i)
		excelTable.Add(p, v)
		
	Next

	GoExcel.Close
	Return excelTable

End Function

 

 

 

 

0 Likes
194 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Hi @ProRuzneDrobnosti 

 

Programming/coding questions are best asked in the ilogic/vba forum here.

 The sample you presented is almost unusable for the methods you propose. See this forum sample here. It should need some tweaks to get it working as you need. All that's missing is picking up the values from excel. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

ProRuzneDrobnosti
Contributor
Contributor
Thank you for your answer!