I'm needing to save selected features in the feature tree as a library feature. I'm using code from Deepak Gupta I found here. In my main module I call the SaveAs module and pass into it features I want to select.
SaveAs_filename.main sel_feat, axis_normal, normalPlane
In SaveAs_filename.main I set my document name as sel_feat.name with extension sldflp. I don't think this module will save out to a .sldflp format the way it is currently written. I changed the extension to .sldprt and the code worked fine.
What do I need to change in order to save my selections as a .sldflp format in the background without opening the .sldflp file afterwards?
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim strNewPath As String
Dim nErrors As Long
Dim nWarnings As Long
Dim Dir As String
Dim Path As String
Function BrowseFolder(Optional Caption As String, _
Optional InitialFolder As String) As String
Dim SH As Shell32.Shell
Dim F As Shell32.Folder
Set SH = New Shell32.Shell
Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
If Not F Is Nothing Then
BrowseFolder = F.Items.item.Path
Sub main(sel_feat, axis_normal, normalPlane)
Path = BrowseFolder(Caption:="Select A Folder/Path")
If Path = "" Then
MsgBox "Please select the path and try again"
Path = Path & "\" & sel_feat.Name & ".sldflp"
bool = swModel.extension.SaveAs(Path, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings)