I've looked at the solidworks API Help and I am not sure on which command to use.
My code that I currently have copies from a specific cell and puts the value into the custom property that I've defined.
What I would like to do is to copy the value of a custom property and paste it in a specific cell of the workbook first. then copy the value of a different cell back to a different solidworks property. I have the last part, but I'm looking to do the first part.
Any help would be fantasic! Thank you!
Here is the code that I have.
Code: Select all
'Dim swApp As Object
'Dim Part As Object
'Dim boolstatus As Boolean
'Dim longstatus As Long, longwarnings As Long
'Option Explicit
Dim xlRange As Object
Dim swCustPrpMgr As SldWorks.CustomPropertyManager
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim xlApp As Object
Dim xlSheet As Object
Dim xlBooks As Object
' Open Excel workbook
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "C:\STOCKED INVENTORY LIST.xls"
Set xlSheet = xlApp.ActiveSheet
' Copy data from Excel to Custom Properties
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
' Set xlApp = GetObject(, "Excel.Application")
' Set xlSheet = xlApp.Sheets(1)
Name = xlSheet.Cells(8, 9)
swModel.DeleteCustomInfo2 "", "RawPartNo"
swModel.AddCustomInfo3 "", "RawPartNo", swCustomInfoText, Name
Name = xlSheet.Cells(9, 9)
swModel.DeleteCustomInfo2 "", "RawOperation"
swModel.AddCustomInfo3 "", "RawOperation", swCustomInfoText, Name
' Close Excel
xlApp.Workbooks.Close
xlApp.Quit
End Sub