AnsweredAssumed Answered

Macro to copy Excel data to Custom Properties

Question asked by Kishore K. on Nov 30, 2020
Latest reply on Nov 30, 2020 by Kishore K.

Hi,

 

I would like to copy the excel data to custom properties. Find out the error in my code. 

 

Adding to this I would like to add this data for all configuration in the part.

 

 

Sub Main()

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean


Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc


Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
xlApp.Visible = False
'Excel Location
Set xlWB = xlApp.Workbooks.Open("D:\PDM macro data card.xls")

'Custom property
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Set swCustPropMgr = Part.Extension.CustomPropertyManager("")

Dim Text1 As String
Dim Text2 As String

Text1 = xlWB.Sheets(1).Cells(2, 1).Value
Text2 = xlWB.Sheets(1).Cells(4, 1).Value

 

swCustPropMgr.Add2 Text1, swCustomInfoText, Text2

 

End Sub

Outcomes