UDF > Word >


_Word_DocSave

Enregistre le document Word spécifié

#include <Word.au3>
_Word_DocSave ( $oDoc )

Paramètre

$oDoc Objet document Word

Valeur de retour

Succès: Retourne 1.
Échec: Retourne 0 et définit @error <> 0.
@error: 1 - $oDoc n'est pas un objet
2 - Le document spécifié n'a pas été enregistré avant, s'il vous plaît utiliser _Word_DocSaveAs() d'abord
3 - Une erreur s'est produite lors de l'enregistrement du document spécifié. @extended contient le code d'erreur COM

Remarque

Si le document n'a pas été enregistré avant ou a été ouvert en lecture seule, la boîte de dialogue "Enregistrer Sous" invite l'utilisateur à donner un nom de fichier.

En relation

_Word_DocSaveAs

Exemple

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>

; Copie \Extras\Test.doc vers @TempDir
If FileCopy(@ScriptDir & "\Extras\Test.doc", @TempDir & "\_Word_Test.doc", $FC_OVERWRITE) = 0 Then Exit MsgBox($MB_SYSTEMMODAL, _
        "Word UDF: _Word_DocSave Example", "Couldn't copy '.\Extras\Test.doc' as '_Word_Test.doc' to the @TempDir directory.")
; Crée un objet application
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Ouvre le document test
Local $oDoc = _Word_DocOpen($oWord, @TempDir & "\_Word_Test.doc")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error opening '_Word_Test.doc'." & @CRLF & "error = " & @error & ", @extended = " & @extended)

;
; Enregistre le document
;
; Insert text at the beginning
Local $oRange = _Word_DocRangeSet($oDoc, -1)
$oRange.Text = "Bold text at the beginning. "
$oRange.Bold = True
; Enregistre  le document
_Word_DocSave($oDoc)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", "Document successfully saved as '" & _
        $oDoc.FullName & "'")