Add excel reference

Add excel reference

Anonymous
Not applicable
510 Views
6 Replies
Message 1 of 7

Add excel reference

Anonymous
Not applicable
Hello everybody!

im writing a macro that needs to read data out of a excel file. Im inside the inventor macro editor, and i would like to add the reference to excel so that i can connect to a excel spreadsheet, but i am not able to find the "tools- references..." button.

how do i add references/connect to a excel file inside the inventro macro editor?

thanks

Igor
0 Likes
511 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
See the attached file.

I personally don't reference the Excel library very often because the reference is version specific. So everytime you upgrade Excel you'll have to exchange references in order for your code to continue to work. Instead I use late binding. You won't be able to use IntelliSense (content sensitive dropdown list) because the library isn't referenced. You could reference the library while you're developing then unreference it when development is done (i.e. late binding).

Dim oExcelApp as Object
Set oExcelApp = GetObject(, "Excel.Application";)
0 Likes
Message 3 of 7

Anonymous
Not applicable
thank you very much!

do you know if there is a element that tells me the absolute path to the project folder?

thanks

Igor
0 Likes
Message 4 of 7

Anonymous
Not applicable
Dim moInventorApp As Inventor.Application
Dim moFileLocations As Inventor.FileLocations
Dim sCurrentProject As String

....

Set moFileLocations = moInventorApp.FileLocations
sCurrentProject = moFileLocations.FileLocationsFile
0 Likes
Message 5 of 7

Anonymous
Not applicable
thank you very much! you made my day! 🙂
0 Likes
Message 6 of 7

Anonymous
Not applicable
oh,

any chance to have it without the projectfile at the end of the path? just the path itself to the main directory?

thnx

igor
0 Likes
Message 7 of 7

Anonymous
Not applicable
I'm not aware of something that would return just the path but you can pull it out the the path/file string very easily...

Dim sPath as String
sPath = mid(sCurrentProject,1,InstrRev(sCurrentProject,"\"))

In the above, sPath will end with \ which can be helpful to have depending on how you are intending to use it but if you don't want it at the end of the string then do the following:

sPath = mid(sCurrentProject,1,InstrRev(sCurrentProject,"\") - 1)
0 Likes