|
WordWriter in ASP
> ASP Reference
> Save Method
Syntax:
[VBScript]
Sub Save(Output As Variant,_
[optional] attachmentName As String,_
[optional] OpenInBrowser As Boolean)
Object:
Description:
Saves the generated Word file on the server or streams it to the client.
The first parameter of the Save method may be either a file path
or the ASP Response object. If you pass Save a file path, WordWriter
will save the generated file on the server. If you pass Save the
Response object, WordWriter will stream the generated file to the client.
You can call Save more than once for a single instance of
WordTemplate. This allows you to save more than one copy
of a generated file, and/or both save the file on the server and stream it to the client.
Using multiple Process and Save calls,
you can generate multiple files from a single template and an updated data source.
Parameters:
Output
Output may be either a file path or the ASP Response object.
To save the generated Word file on the server, Output
should be a complete path and file name. WordWriter will save the file
to this location. If a file with the same name exists, it will be overwritten
by the new Word file. To stream the generated Word file to the client,
Output should be the Response object.
[attachmentName]
When the generated file is streamed to the client, you can set this
optional parameter which specifies a name for the generated Word file;
this name will be displayed in the download dialog when the file is
streamed to the browser.
[openInBrowser]
When the generated file is streamed to the client, you can set this
optional parameter. If openInBrowser is set to true, and the
user chooses to open the file, the file will open in the browser
window. If openInBrowser is set to false, and the
user chooses to open the file, the file will open in Microsoft Word.
By default, the file will open in the browser window. Note: not all
browsers can embed a Word file in the browser window.
Examples:
[VBScript]
'--- Save the generated file on the server.
arrValues = Array("SoftArtisans", "WordWriter", "http://www.softartisans.com")
arrNames = Array("CompanyName", "ProductName", "URL")
Set oWW = Server.CreateObject("SoftArtisans.WordTemplate")
oWW.Open("C:\TemplateDirectory\Template.doc")
oWW.SetDataSource arrValues, arrNames
oWW.Process
oWW.Save "C:\Output\Output.doc"
Set oWW = Nothing
[VBScript]
'--- Stream the generated file to the client.
arrValues = Array("SoftArtisans", "WordWriter", "http://www.softartisans.com")
arrNames = Array("CompanyName", "ProductName", "URL")
Set oWW = Server.CreateObject("SoftArtisans.WordTemplate")
oWW.Open("C:\TemplateDirectory\Template.doc")
oWW.SetDataSource arrValues, arrNames
oWW.Process
oWW.Save Response, "Output.doc", False
Set oWW = Nothing
Top

Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.
|