Excel: Add a link to open a 3dxml file

Hello


I have a Macro (VBA), which will read an excel file with References

for each  Reference, we get information from our PLM (Material, mass, preview image, PDF, 3dxml file) .....

The macro completes the Excel file by adding this information

when there is an image or a PDF, we add a link => from Excel, we click on the link, the image or PDF opens!

example

    ' "=HYPERLINK(""image\R13550220.jpg"")"
    MyImage="=HYPERLINK(" &"""" & "image\" & Myref & ".jpg" & """" & " & " & "ok" & """" & """ & ")"
    XL.ActiveSheet.Cells(iRow, iCol). FormulaR1C1 = Myimage

Problem, in this way ( add a link to the file 3dxml    ' "=HYPERLINK(""3dxml\R13550220.3dxml"")"

if I click on the link, nothing happens :-(

HELP

how to add a link or command in an Excel file, to open a 3dxml file!

Warning: the operation must be done from a Macro! not interactive!

(see example in the attached file)


rpm20-rupture-raccord-2019-09-10-08-04.zip

Hello

Here is an example of a Solidworks macro for opening a 3D xml file via a hyperlink in Excel:

Be careful, don't forget to put the reference to "Microsoft Excel xx.0 Object Library" and there must be a default application defined in Windows to open 3Dxml files.

Sub OpenExcel()

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Dim wbk As Excel.Workbook
Dim sht As Excel.Worksheet

With xlApp
    .Visible = True
    Set wbk = .Workbooks.Add
    Set sht = wbk.ActiveSheet
End With

sht.Hyperlinks.Add sht.Range("A1"), "C:\Temp\Pièce1.3DXML"

End Sub

It is possible to pass other arguments to the Hyperlinks.Add function, see HERE

Kind regards

1 Like