AnsweredAssumed Answered

SaveAs is not saving the file

Question asked by Harold Black on Dec 19, 2019
Latest reply on Dec 20, 2019 by Harold Black

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 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?


Option Explicit

Private Const BIF_RETURNONLYFSDIRS As Long = &H1
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
End If

End Function

Sub main(sel_feat, axis_normal, normalPlane)

axis_normal.Select True
normalPlane.Select True
sel_feat.Select True

Path = BrowseFolder(Caption:="Select A Folder/Path")

If Path = "" Then
MsgBox "Please select the path and try again"
Path = Path & "\" & sel_feat.Name & ".sldflp"
End If

bool = swModel.extension.SaveAs(Path, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings)

End Sub