|
You may add extra error level checks after an execution of ExecCmd. ExecCmd() returns the error level from the executed file. For Tidy, "0"
means "OK", "1" means "There are warnings", "2" means "There are errors". When errors occur, Tidy can't continue.
3.2
This section shows you how to customize an extra FrontPage menu with the
call to the Tidy VBA sub procedure.
How to guide:
- Open FrontPage.
- Activate the 'Tools|Macro|Visual Basic Editor' menu item. This
should open up the VBA editor of FrontPage.
- Right click the Modules folder and select 'Import File...' and
import the ExecuteCmd.bas file. Activate import file again and select the
Tidy.bas file. See figure below. You should now have at least two modules
in the Modules folder - one named ExecuteCmd and one named Tidy.
- If there is an empty Module1 module you can safely delete it.
- Import the form file Form_tidy_output.frm which defines the dialog
that will be used to display the (output) result from tidy.
- Go into the Tidy module and define the 4 constants as described
earlier in section 3.1.

» Figure illustrating the import file feature of VBA
-
Close the VBA editor by activating 'File|Close' or press Alt+Q. You're now back in FrontPage.
-
Select 'Tools|Customize..." to open up the Customize dialog.
-
Select the Commands tab in the Customize dialog (see figure below).

» The Tools|Customize dialog.
-
Select New Menu in the categories list box. The right hand side list box should contain at least one command available named "New
Menu".
-
Click and drag the "New Menu" command up to the main menu of FrontPage at a preferred location e.g. after the Format menu item. The
location where you insert should be marked by a vertical insertion bar.
-
Right click at your newly inserted menu item to open a special customize context menu.
-
The context menu contains a menu item called New Name where you can specify a name for your menu item. I've used the "E&xtras"
name, where the ampersand indicates which letter that acts as shortcut - and therefore will be underlined.
-
In the Customize dialog select the Macro item from the categories list box. Two new commands should now be available at the right
hand side. Select the "Custom Menu Item" and drag it to your new Extras menu.
-
Again select the context menu by right clicking and give the new menu item a name e.g. "&Tidy Document".
-
Within the opened context menu, use the "Assign macro" item to
specify which macro to execute when the menu item is activated by the
end-user. Select the Tidy macro (the one coming from the Tidy VBA sub
procedure).
-
Close the Customize dialog.
-
You should now be up and running. Test that everything works.
I have shown you how you can integrate HTML Tidy into FrontPage and thereby improve the overall quality of your web documents in an easy
manner.
The next obvious thing to implement would be an offline validator that
can be executed from within FrontPage. That would really be something that
would increase the quality of the web documents. I suggest reading my
accompanying article "Integrating
Validation into Microsoft FrontPage" which explains how you can add
offline validation to your web page. It's as good as the validator available
from http://validator.w3.org/.
Nice coding.
A.1 DOCTYPE problem in FrontPage 2000
Within FrontPage 2000, a document containing the !DOCTYPE specification (typically the first line) may not be preserved after an execution of
the Tidy macro.
This problem does not occur in FrontPage 2002.
Cause: Tidy is run on the ActiveDocument.DocumentHTML string which does not contain the DOCTYPE specification.
Resolution: Change to FrontPage 2002.
Comments: The ActiveDocument.DocumentHTML string may not contain all code from the web page, which may lead to other problems. One
example is the text of the shared borders, which may contain HTML code. This HTML code will not be repaired by Tidy.
A.2 Possible XML declaration problem in FrontPage 2000
Recent HTML Tidy builds creates an XML declaration when 'output-xhtml' is
set to 'yes'. This is, in fact, good. Older builds forgot the XML
declaration, even when using other encodings than UTF-8 or UTF-16. I'm
afraid this could cause big problems. Since FrontPage 2000 doesn't like XML
declarations, it moves them into the body element.
A.3 Long file name handling
In case of long file names, e.g. if you have installed HTML Tidy in a folder with long file names (e.g. under C:\Program Files), the VB code
should be changed to quote the file names.
In tidy.bas the following should be modified from:
Dim strCmd As String
strCmd = TIDY_PROGRAM_FILE & " -f " & TIDY_ERROR_FILE & _
" -config " & TIDY_CONFIG_FILE & " " & TIDY_TEMP_FILE
|
|