Home|TOC|Index|Previous  

Extending WordToWeb with your Own Programs and Scripts

WordToWeb 2.5 allows end users and/or third-party developers to add their own functionality to the WordToWeb conversion process by writing custom macros, scripts or programs.

Custom programs or scripts are invoked automatically during the conversion process. WordToWeb provides access to the conversion process at two points:

Pre-Conversion Macros

Pre-conversion macros must be written in Visual Basic for Applications (Word 97 or later) or WordBasic (Word 95). These macros are run before WordToWeb converts the document to HTML. The macro is run on a copy of each source document (the source document itself will not be modified). The macro should be saved in the Normal template.

In designing a pre-conversion macro, follow these rules:

  • You can assume the source document will be active and the cursor will be positioned at the top of the document.
  • Do not close or save the active document.
  • If you open another document, be sure to close it and reactivate the original document.

Post-Conversion Programs or Scripts

Post-conversion programs/scripts are run on each HTML file created by WordToWeb. The program or script will be called once for every HTML page created.

The path to the HTML files is passed as a command line argument when your program is called:

yourprogram <full path to HTML page>

To create a post-conversion program or script you can use any Windows programming or scripting language (C/C++, Visual Basic, etc.). Post-conversion scripts are simple command line programs; they do not require a visual interface. If you use an interpreted scripting language like Perl, then the associated executable must also be installed on your computer.

Using Perl

An example post-conversion script is included which uses Perl (Practical Extraction and Reporting Language). Perl is an excellent choice for manipulating HTML because it has very strong text processing capabilities. Also, many webmasters and programmers are familiar with using Perl in conjunction with HTML because it is a common choice for CGI programs.

To use Perl with WordToWeb, you must have the Perl executable properly installed on your computer, and you must have defined an association between the extension you use for your script (usually .pl) and perl.exe.

Perl for 32-bit Windows is a free download. You can obtain the latest version of ActivePerl (tm) from ActiveState Tool Corporation's website, http://www.activestate.com.

Solutionsoft also markets Perl Builder, a complete integrated development environment for developing Perl scripts. You can find out more about Perl Builder at http://www.solutionsoft.com/perl.htm.

The Perl Post-Conversion Script Example

WordToWeb includes a simple Perl script which demonstrates how post-conversion scripts work. The included example simply locates all hyperlinks and places <B> </B> tags around them so that all links are bold.

If you are interested in using Perl with WordToWeb, please examine this script and the comments it contains. You can modify this example script to meet your needs.

To Try the Example

  1. Download and install Perl and make sure that the file extension .pl is associated with Perl .exe. Installing the latest version of ActivePerl will take care of this for you automatically.
  2. Open a project in WordToWeb.
  3. In WordToWeb Wizard panel 6, click the More Options button to bring up the Conversion Options dialog box.
  4. Check the Run Post-Conversion Script or Program box.
  5. Fill in the full path to the Perl script you want to run. The example script is called post_convert.pl and is located in the main WordToWeb install directory.
  6. Click OK.
  7. Click Finish to convert your project in the normal way.

Setting Conversion Scripts Programmatically

Conversion scripts are specified in the WordToWeb project file, so you can specify them directly without using the Wizard dialog boxes if you wish.

The settings are in Windows INI file format and can be set using the WritePrivateProfileString API function.

[Extensions]

run_pre=0|1

run_post=0|1

pre_name=<name of pre-conversion script>

post_name=<full path to post-conversion script>

  Home|TOC|Index|Previous  

This page was created on March 25, 2002
Copyright © Solutionsoft, 2002
Please send feedback and suggestions to feedback@solutionsoft.com.