Autodesk Inventor – iLogic – Create a Hyperlink in Excel

Why would you want to create a hyperlink in Excel using Inventor?  Perhaps many reasons. Some companies keep some master data in Excel spreadsheets, and if you are linking an Inventor model with a spreadsheet, why not place a hyperlink to the model PDF, 3D PDF, DWG, DXF, or actual IPT file inside the spreadsheet.

So if you do have a scenario like this – the snippet of code below might come in handy if you’re not a comfortable VB.Net code googler.

The following iLogic rule opens a spreadsheet called “C:\MASTER SPREADSHEET 123.xlsx” on your C drive and puts a hyperlink to the active Inventor document in Cell C3 on Sheet1. Adjust to suit.

Very tasty. Hope you enjoy.

Luke

SyntaxEditor Code Snippet

' Start of iLogic rule =======================================================
' Note this iLogic rule requires a spreadsheet "C:\MASTER SPREADSHEET 123.xlsx" to exist, otherwise you'l get an error.
' Note you'll get an error if you try running this rule in a new document that hasn't yet been saved, as it won't have a filename yet!

' Define Excel Application object
oExcel = CreateObject("Excel.Application")

' Make Excel invisible
oExcel.Visible = False

' Suppress all Excel prompts
oExcel.DisplayAlerts = False

Dim oSourceBook = oExcel.Workbooks.Open("C:\MASTER SPREADSHEET 123.xlsx")

' Select the worksheet we want
Dim SourceWorksheet = oSourceBook.Worksheets("Sheet1")

' Add hyperlink to cell C3 - in this case the hyperlink points to this Inventor file. We are also setting a 'tooltip' for the hyperlink to be the name of the active file in Inventor.
' The visible text for the hyperlink is 'Link to Inventor Model'
SourceWorksheet.Hyperlinks.Add(SourceWorksheet.Range("C3"), ThisApplication.ActiveEditDocument.FullDocumentName,,ThisApplication.ActiveEditDocument.FullDocumentName, "Link to Inventor Model")

' Save the spreadsheet
oSourceBook.Save
oSourceBook.Close
oExcel.Quit
oExcel = Nothing

' Open the spreadsheet...
Process.Start("C:\MASTER SPREADSHEET 123.xlsx")

' End of iLogic rule =======================================================
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s