Selected face offset sketch line and connected to global variable macro help

New to macro building so trying to start small while I get my head around it all!

I would like to create an offset line within a sketch from a selected face and link the dimension to a variable.

setup:

Open all new parts using a standard part and assembly template to set up the common global variables I want to use
Global variables created by template - "rebate"
Sketch on the target surface open with one face selected

Run macro:

Macro uses the edges of the pre-selected face to act as the input edges for an inward offset
The offset is applied and then dimension changed to the global variables "rebate"
The selected face and edges are deselected
End

I have had a bit of a play around with codes I have found but can't work out how to link the created offset dimension to a global variables. Any one help me understand how to select the created dimension offset command and linking my variable.

Thanks
Krishna

<p>Dim swApp As Object</p><p></p><p>Dim Part As Object</p><p>Dim ModDoc As ModelDoc2</p><p>Dim boolstatus As Boolean</p><p>Dim longstatus As Long, longwarnings As Long</p><p></p><p></p><p>Sub main()</p><p>Set swApp = Application.SldWorks</p><p>Set ModDoc = swApp.ActiveDoc</p><p>Dim SelMgr As SelectionMgr</p><p>Dim EdgeCount As Integer</p><p>Dim Edges() As Edge</p><p>Dim SelFace  As Face2</p><p>Dim SelData As SelectData</p><p>Dim SelectedCount As Integer</p><p></p><p>If ModDoc Is Nothing Then</p><p>Else</p><p>     Set SelMgr = ModDoc.SelectionManager</p><p>     If SelMgr.GetSelectedObjectCount2(-1) = 1 Then</p><p>          Select Case SelMgr.GetSelectedObjectType3(1, -1)</p><p>                    Case swSelectType_e.swSelFACES</p><p>                         Set SelFace = SelMgr.GetSelectedObject6(1, -1)</p><p>                         If SelFace Is Nothing Then</p><p>                         Else</p><p>                              EdgeCount = SelFace.GetEdgeCount</p><p>                              Edges = SelFace.GetEdges</p><p>                              Set SelData = SelMgr.CreateSelectData</p><p>                              ModDoc.ClearSelection2 (True) ' This Clears the selected Face</p><p>                              SelectedCount = SelMgr.AddSelectionListObjects(Edges, SelData)</p><p>                              swApp.SendMsgToUser2 "There Were " & SelectedCount & " Edges Selected", _</p><p>                          swMessageBoxIcon_e.swMbInformation, swMessageBoxBtn_e.swMbOk</p><p>                          Set Part = swApp.ActiveDoc</p><p>                          boolstatus = Part.SketchOffsetEntities2(-0.00001, False, False)</p><p>                          '' connect "rebate" to the offset above</p><p>                        Part.ClearSelection2 True</p><p>             </p><p>                         End If</p><p>          End Select</p><p>End If</p><p></p><p></p><p>End If</p><p></p><p></p><p>End Sub</p>
SolidworksApi macros