' ' SavePostwithDoc.bas ' ' Author: Kyle Kershaw ' Organization: Delcam USA ' Date: May 20, 2008 ' Copyright (c) 2008, Delcam USA ' ' macro to save last used post path with document ' path is saved when document is exited (deactivted) ' changes to saved path when switching between or opening document ' Option Explicit ' record post used when deactivating document Private Sub Application_DocumentDeactivate2 (Doc As FeatureCAM.MFGDocument) Dim setup As FMSetup Dim post_name As String Set setup = Doc.ActiveSetup If TypeName(Doc) = "IFMDocument" Then If (setup.Type = eST_Milling) Then Doc.Application.GetMillPostOptions(post_name) ElseIf (setup.Type = eST_Turning ) Then Doc.Application.GetTurnPostOptions2(post_name) ElseIf (setup.Type = eST_Wire) Then Doc.Application.GetWirePostOptions3(post_name) End If ElseIf TypeName(Doc) = "IMFDocument" Or _ TypeName(Doc) = "ITSFDocument" Then Doc.Application.GetMillPostOptions(post_name) End If Doc.SetUserAttribute("post", post_name,,False) End Sub ' set post when switching between documents Public Sub Application_DocumentActivate2(Doc As FeatureCAM.MFGDocument) If Not Doc.Name = "" Then SetPost(Doc) End If End Sub ' set post when opening document Public Sub Application_DocumentOpen2(Doc As FeatureCAM.MFGDocument) SetPost(Doc) End Sub ' switch to post path saved in user attribute "post" Private Sub SetPost(Doc As FeatureCAM.MFGDocument) Dim post As String Dim setup As FMSetup Set setup = Doc.ActiveSetup post = Doc.UserAttribute("post") If Not post = "" Then If TypeName(Doc) = "IFMDocument" Then If (setup.Type = eST_Milling) Then Doc.Application.SetMillPostOptions4(post) ElseIf (setup.Type = eST_Turning ) Then Doc.Application.SetTurnPostOptions2(post) ElseIf (setup.Type =eST_Wire ) Then Doc.Application.SetWirePostOptions3(post) End If ElseIf TypeName(Doc) = "IMFDocument" Or _ TypeName(Doc) = "ITSFDocument" Then Doc.Application.SetMillPostOptions4(post) End If End If End Sub