iLogic code to pull iProperties from Microsoft excel file

iLogic code to pull iProperties from Microsoft excel file

Anonymous
Not applicable
696 Views
4 Replies
Message 1 of 5

iLogic code to pull iProperties from Microsoft excel file

Anonymous
Not applicable

Hello, I am very new to iLogic, but have been interested in getting to know it better.  I am trying to write a piece of code that will allow me to pull information from an excel file and insert that into the iProperties for the part specified.  the excel file is very simple and in the first row the columns read as follows: PART NUMBER, DESCRIPTION, PROJECT, TITLE

I have got the code to read from the file, but it only fills out the iProperties on the part with information listed from the first part on the list in the excel file. 

part_number = InputBox("Plese enter the part number", "Get Data")

i = GoExcel.FindRow("C:\LSE Vault\Data\iProperties_new.xlsx", "Sheet1", "PART NUMBER", "=", part_number, "DESCRIPTION", "=", part_description, "PROJECT", "=", part_project, "TITLE", "=", part_title)
part_description = GoExcel.CurrentRowValue("DESCRIPTION")
part_project = GoExcel.CurrentRowValue("PROJECT")
part_title = GoExcel.CurrentRowValue("TITLE")

iProperties.Value("Project", "Part Number") = part_number
iProperties.Value("Project", "Description") = part_description
iProperties.Value("Project", "Project") = part_project
iProperties.Value("Summary", "Title") = part_title

MessageBox.Show("All properties have been applied to " & part_number, "Success")

 

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

Mark.Lancaster
Consultant
Consultant

@Anonymous 

 

Programming needs should be asked in the Inventor customization for best results.  https://forums.autodesk.com/t5/inventor-customization/bd-p/120

 

I will have the moderator relocate your posting there to best suit your needs.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 3 of 5

Sergio.D.Suárez
Mentor
Mentor

Hi, Try this code I have not tried it, but I think it should work. regards

 

Dim Dirxlsx As String = "C:\LSE Vault\Data\iProperties_new.xlsx" 
Dim osheetbom As String = "Sheet1"     

xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlWorkbook = xlApp.Workbooks.Open(Dirxlsx)
xlWorksheet = xlWorkbook.Worksheets.Item(osheetbom)

Dim row As Integer = 2                 ''' Indicate from which row the copying will start to excel
iProperties.Value("Project", "Part Number") = xlWorksheet.Range("A" & row).Value iProperties.Value("Project", "Description") = xlWorksheet.Range("B" & row).Value iProperties.Value("Project", "Project") = xlWorksheet.Range("C" & row).Value iProperties.Value("Summary", "Title") = xlWorksheet.Range("D" & row).Value MessageBox.Show("All properties have been applied", "Success") xlWorkbook.Close (True) xlApp.Quit

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 4 of 5

Anonymous
Not applicable

Thank you, this does work, however I do not want just the second row to be the constant value. I want to enter the part number and the rule pull the information from the specific row the part number is in

0 Likes
Message 5 of 5

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Try the following code, maybe it should work. In a moment I will prove it. regards

 

Dim Dirxlsx As String = "C:\LSE Vault\Data\iProperties_new.xlsx" 
Dim osheetbom As String = "Sheet1"     

xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlWorkbook = xlApp.Workbooks.Open(Dirxlsx)
xlWorksheet = xlWorkbook.Worksheets.Item(osheetbom)

part_number = InputBox("Plese enter the part number", "Get Data")

Dim j As Integer = 1
 
Line1 :
oTest = xlWorksheet.Range("A" & j).Value
 
If oTest <> "" Then 
	j = j + 1
	GoTo Line1
End If

For row = 2 To j
	If xlWorksheet.Range("A" & Row).Value = part_number Then
		iProperties.Value("Project", "Part Number") = xlWorksheet.Range("A" & Row).Value
		iProperties.Value("Project", "Description") = xlWorksheet.Range("B" & Row).Value
		iProperties.Value("Project", "Project") = xlWorksheet.Range("C" & Row).Value
		iProperties.Value("Summary", "Title") = xlWorksheet.Range("D" & Row).Value
		MessageBox.Show("All properties have been applied", "Success")

	End If
Next

xlWorkbook.Close (True)
xlApp.Quit

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes