AnsweredAssumed Answered

Run PDM task to open/read excel file

Question asked by Husein Delic on Mar 26, 2018
Latest reply on Mar 27, 2018 by Husein Delic



I have a macro that opens and read from an excel file and adds custom properties to SW part. I am looking to integrate it in PDM task, but it looks like it needs

to run it, which PDM task cant handle? I have also tired to use execution command to open the excel file which works, but still cant read from it. Any ideas or suggestions are welcome.




Here is the macro which I reduced to keep it simple:


Dim swApp           As SldWorks.SldWorks

Dim xlApp           As Excel.Application

Dim xlSheet         As Excel.Worksheet

Dim xlBooks         As Excel.Workbooks

Dim swModel         As SldWorks.ModelDoc2

Dim nErrors         As Long

Dim nWarnings       As Long




Sub main()


    Set swApp = Application.SldWorks

    Set swModel = swApp.OpenDoc6("<Filepath>", swDocPART, swOpenDocOptions_Silent, "", nErrors, nWarnings)

    swApp.Visible = True


    Set xlApp = CreateObject("Excel.Application")

    xlApp.Visible = True

    xlApp.Workbooks.Open "C:\EPDM\Projects\BOM_Part Number.xlsx"

    Set xlSheet = xlApp.ActiveSheet


End Sub