This documentation is archived and is not being maintained.

Save Method (Document Object)

Visual Studio .NET 2003

Saves the document.

[Visual Basic .NET]
Public Function Save( _
   Optional ByVal FileName As String =  _
) As vsSaveStatus
[Visual Basic 6]
Function Save( _
   Optional ByVal FileName As String =  _
) As vsSaveStatus
HRESULT __stdcall Save(
   BSTR FileName,
   /* [out, retval] */ vsSaveStatus* retVal
vsSaveStatus Save(
   string FileName
[JScript .NET]
public function Save(
   FileName : String
) : vsSaveStatus


Optional. The name in which to save the document. Defaults to the pathname associated with this document. That is, if an empty string is passed, the document is saved with its current name.

Return Value

Returns a vsSaveStatus constant indicating whether or not the save was successful.


If FileName cannot be written, such as when the disk is full or there are write permission problems, then Save produces an error. The file is saved with a new name based on FileName.


Sub SaveExample()
   Dim objDoc As Document
   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")
   ' Create a document reference.
   objDoc = DTE.Documents.Item(1)
   ' Save the new text file.
End Sub

See Also

SaveAll Method | Saved Property (General Extensibility)

Applies To: Document Object