How do I communicate between inventor and excel?

Hello

I have a problem, I would like to retrieve information on the visual basic of inventor that is in a workbook that is already open.

Hello

have you tried with the command: GoExcel.CellValue,

Like what:

 Length=GoExcel.CellValue("PIECE 1.xls", "Sheet1", "C2")

To take it into account, you must save the Excel file without necessarily closing it.

Hello

It didn't work 

GoExcel.CellValue <-- it doesn't know this function.

I'm on inventor 2021 if it can help you.

 

for this operation, it is not necessary to create a Sub. made with inventor 2019

 


capture.jpg

Hello

Added Reference for Micosoft Excel:

 

Then use this code:

Public Sub ReadExcel()
    Dim excelApp As Excel.Application
    Set excelApp = GetObject(, "Excel.Application")

    Dim workBook As workBook
    Set workBook = excelApp.Workbooks.Open("C:\Temp\Test.xlsx")

    Dim sheet As WorkSheet
    Set sheet = workBook.Sheets.Item("Feuille1")

    Dim Val1 As String
    Val1 = sheet.Cells(22, 3)
    Debug.Print Val1

    excelApp.Quit
End Sub

 

2 Likes

My Excel file is already open so I can't do Open, I need something else to choose my Excel.

I did that but Vall is empty. The msgbox doesn't show me anything.

The code, as you wrote it, works well on my end.

Well, for me, the Msbox Vall shows me nothing at all.