Message-ID: <884780940.9509.1711692565033.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9508_1227058383.1711692565033" ------=_Part_9508_1227058383.1711692565033 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html SharePointIntegration.Save(WordApplication, Document, Microsoft.= SharePoint.SPListItem, String)

SharePointIntegration.Save(WordApplication, Document, Microsoft.Sha= rePoint.SPListItem, String)

Introduced in build 4.5

=20

Description

=20

Writes a Document to a file and sa= ves it to a SharePoint List Item.

=20
C#
=20
public static void Save(this WordApplication wordApplication, Document docu=
ment, Microsoft.SharePoint.SPListItem listItem, string fileName)
=20
=20
vb.net
=20
Public Shared Sub Save(ByVal wordApplication As WordApplication, ByVal docu=
ment As Document, ByVal docLib As Microsoft.SharePoint.SPListItem, ByVal fi=
leName As String)
=20
=20

Parameters

=20
wordApplication
The curren= t WordApplication object from which Save is being called=20
document
The=20 Document to save.=20
listItem
The SharePoint List Item= to which the file will be saved=20
fileName
Filename of the=20 Document=20

Exceptions

=20
System.Exception
Thrown i= f there is an error saving the file.=20

Remarks

=20

The W= ordApplication.Preserve property is used to specify the way WordWriter = will save the document. When the preserve property is set to t= rue, WordWriter attempts to preserve all formatting and features that it do= esn't directly support. This includes Fields, Footnotes, Hyperlinks, Commen= ts, and Anchored Images. When the preserve property is false, = only those features directly supported by WordWriter will be preserved. Thi= s includes all Tables, Lists, Headers and Footers.

=20
=20 Icon=20
=20

This is an extension method for the WordApplication object to be used fo= r saving documents to a SharePoint List Item from within SharePoint. To use= this method, you must add a reference to SoftArtisans.OfficeWriter.WordWri= ter.SharePointIntegration.dll

=20
=20
=20

Examples

=20
C#
=20
//--- Retrieve current AllowUnsafeUpdates value
bool currentAllowUnsafeUpdates =3D list.ParentWeb.AllowUnsafeUpdates;

//--- You must allow unsafe updates in order for the file to be saved in th=
e
//--- List from a web application
list.ParentWeb.AllowUnsafeUpdates =3D true;
wa.Save(doc, listItem, "populated.doc");

//--- Update the list
listItem.Update();

//--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates;
        
=20
=20
vb.net
=20
'--- Retrieve current AllowUnsafeUpdates value
Dim currentAllowUnsafeUpdates As Boolean =3D list.ParentWeb.AllowUnsafeUpda=
tes

'--- You must allow unsafe updates in order for the file to be saved in the
'--- List from a web application
list.ParentWeb.AllowUnsafeUpdates =3D True
wa.Save(doc, listItem, "populated.doc")

'--- Update the list
listItem.Update()

'--- Return the AllowUnsafeUpdates value to its original state
list.ParentWeb.AllowUnsafeUpdates =3D currentAllowUnsafeUpdates
        
=20
------=_Part_9508_1227058383.1711692565033--