Saves the active document to the specified name in the specified format.
.NET Syntax
Visual Basic (Usage) | |
---|
Dim instance As IModelDocExtension
Dim Name As System.String
Dim Version As System.Integer
Dim Options As System.Integer
Dim ExportData As System.Object
Dim ReferencePrefixOrSuffixText As System.String
Dim AddTextAsPrefix As System.Boolean
Dim Errors As System.Integer
Dim Warnings As System.Integer
Dim value As System.Boolean
value = instance.SaveAs2(Name, Version, Options, ExportData, ReferencePrefixOrSuffixText, AddTextAsPrefix, Errors, Warnings) |
Parameters
- Name
- Full pathname of the document to save; the file extension indicates any conversion that should be performed (for example, Part1.igs to save in IGES format) (see Remarks)
- Version
- Format in which to save this document as defined in swSaveAsVersion_e (see Remarks)
- Options
- Option indicating how to save the document as defined in swSaveAsOptions_e (see Remarks)
- ExportData
- IExportPdfData object for exporting drawing sheets to PDF (see Remarks)
- ReferencePrefixOrSuffixText
- Text to prefix names of reference files (AddTextAsPrefix is true) or text to suffix them (AddTextAsPrefix is false); empty string to neither prefix nor suffix the names of reference files; valid only for assemblies (see Remarks)
- AddTextAsPrefix
- True to prefix names of reference files with ReferencePrefixOrSuffixText, false to suffix names of reference files with ReferencePrefixOrSuffixText; valid only for assemblies and when ReferencePrefixOrSuffixText is a non-empty string (see Remarks)
- Errors
- Errors that caused the save to fail as defined in swFileSaveError_e (see Remarks)
- Warnings
- Warnings or extra information generated during the save operation as defined in swFileSaveWarning_e (see Remarks)
Return Value
True if the save is successful, false if not
Example
'VBA
'Preconditions:
'1. Open C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2019\samples\tutorial\advdrawings\98food processor.sldasm.
'2. Ensure c:\temp exists.
'Postconditions:
'1. Silently saves a copy of the assembly (food_processor_Suff.sldasm) and re-named reference files (*_Suff.sldprt) to c:\temp.
'2. Opens the saved assembly.
'3. Observe the re-named components in the FeatureManager design tree.
' NOTE: Because the model is used elsewhere, do not save changes.
'=========================================
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim boolstatus As Boolean
Dim FileName As String
Dim DIR As String
Dim EXT As String
Dim opt As Long
Dim lErrors As Long
Dim lWarnings As Long
Sub main()
DIR = "c:\temp\"
EXT = ".SLDASM"
Set swApp = Application.SldWorks
swApp.Visible = True
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
'1 = swSaveAsOptions_Silent
'4 = swSaveAsOptions_SaveReferenced
'512 = swSaveAsOptions_CopyAndOpen
opt = 512 + 4 + 1
FileName = DIR & "food_processor_Suff" & EXT
boolstatus = swModelDocExt.SaveAs2(FileName, 0, opt, Nothing, "_Suff", False, lErrors, lWarnings)
End Sub
Remarks
See Also
Availability
SOLIDWORKS 2019 SP01, Revision Number 27.1