Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objVars As SolidEdgeFramework.Variables
Dim objVar1 As SolidEdgeFramework.variable
Dim objXLS As Excel.Workbook
Dim objSheet As Excel.Worksheet
Dim objCell As Excel.Range
Const XLS_FILE = "T:\vbtests\testcases\Variables.xls"
' Report errors
Const PI = 3.14159265358979
' Create/get the application with specific settings
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
'Get the Varialbes collection
Set objVars = objDoc.Variables
'Open the XLS application and the XLS file and copy the cell into ClipBoard
Set objXLS = GetObject(XLS_FILE)
Set objSheet = objXLS.ActiveSheet
Set objCell = objSheet.Cells(2, 1)
Call objCell.Copy
'Create the variable with Formula linked to the XLS cell
Set objVar1 = objVars.AddFromClipboard(pName:="Length")
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objVars = Nothing
Set objVar1 = Nothing
Set objXLS = Nothing
Set objSheet = Nothing
Set objCell = Nothing
End Sub