Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Introducedin
4.1.0.1379

...

4.1.0.1379
Description

Excerpt

Sets the MailMerge's

...

data

...

source

...

to

...

a

...

SharePoint

...

View.

...

A

...

MailMerge

...

by

...

default

...

treats

...

the

...

page

...

content

...

as

...

a

...

repeat

...

block,

...

repeating

...

the

...

page

...

content

...

for

...

each

...

row

...

unless

...

NEXT

...

fields

...

are

...

used.

...

If

...

the

...

WordTemplate.EnableNEXTFields

...

property

...

is

...

set

...

to

...

true,

...

the

...

NEXT

...

field

...

can

...

also

...

be

...

used

...

to

...

indicate

...

that

...

the

...

next

...

row

...

of

...

data

...

should

...

be

...

inserted

...

instead

...

of

...

the

...

current

...

row

...

at

...

the

...

next

...

occurence

...

of

...

the

...

merge

...

fields.

...

Signature
C#
C#
public void SetMailMerge(this WordTemplate template, Microsoft.SharePoint.SPView view, Microsoft.SharePoint.SPList list)
{signature}
{signature:
}
Signature
vb.net
vb.net
Public Sub SetMailMerge(ByVal template As WordTemplate, ByVal view As Microsoft.SharePoint.SPView, ByVal list As Microsoft.SharePoint.SPList)
{signature}
{parameters}
{param:template}Current WordTemplate that is calling SetMailMerge{param}
{param:view}A SharePoint View to use as a data source.
{param}
{param:list}A SharePoint List to which the view applies{param}
{exceptions}
{exception:ArgumentNullException}[Save|WordTemplate.Save] will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method.
{exception}
{exception:ArgumentException}
{exception}
{remarks}You can call [SetMailMerge|WordTemplate.SetMailMerge] once for each instance of [WordTemplate].  If you are using the Excel 2003 binary template file type 
Parameters
Param
template
template

Current WordTemplate that is calling SetMailMerge

Param
view
view

A SharePoint View to use as a data source.

Param
list
list

A SharePoint List to which the view applies

Exceptions
Exception
ArgumentNullException
ArgumentNullException

Save will throw this exception if null (C#) or Nothing (VB.NET) is passed to the method.

Exception
ArgumentException
ArgumentException

Remarks

You can call SetMailMerge once for each instance of WordTemplate. If you are using the Excel 2003 binary template file type (.xls/.xlt),

you

can

call

SetMailMerge

or

SetRepeatBlock,

but

not

both.

Additionally,

only

the

page

content

is

repeated

for

each

row,

not

the

entire

page

itself.

If

you

wish

to

have

the

page

itself

repeat

for

each

row,

you

will

need

to

remember

to

place

a

page

break

at

the

bottom

of

the

page.

Merge

Fields

for

using

the

SetMailMerge

method

must

not

specify

a

data

source

--

the

data

source

is

implied,

and

using

a

data

source

name

will

cause

WordTemplate

to

throw

an

error.

Valid

merge

field

formats

for

use

with

SetDataSource

include

field

names

(*«fieldname»*) and field ordinals (*«#1»*). {note}This is an extension method for the WordTemplate object to be used for binding SharePoint data to applications from within SharePoint. To use this method, you must add a reference to

(«fieldname») and field ordinals («#1»).

Note

This is an extension method for the WordTemplate object to be used for binding SharePoint data to applications from within SharePoint. To use this method, you must add a reference to SoftArtisans.OfficeWriter.WordWriter.SharePointIntegration.dll

{note} {remarks} {example}{code:csharp|title=C#}

Example
Code Block
csharp
csharp
titleC#


          //--- Set the mail merge
          //--- The data source is the SharePoint View myView
          wt.SetMailMerge(myView, myList);
          wt.Process();
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}

          '--- Set the mail merge
          '--- The data source is the SharePoint View myView
          wt.SetMailMerge(myView, myList)
          wt.Process()
        
{code} {example}