the complete webmaster
tutorials reviews reference
ASP
CGI
FrontPage
HTML
Java
JavaScript

home / articles / frontpage

Extending FrontPage using the SDK and Visual Basic

Introduction

Although FrontPage 98 is one of the better web site management packages around, the rapid evolution of the web ensures that it will never do everything you want it to do. And although FrontPage 98 had some substantial improvements over the 97 version, there is still plenty of room for improvement.

If you have experience of using either Visual Basic or Visual C++, then you will be easily able to extend the functionality of FrontPage. Microsoft's FrontPage SDK contains detailed information about extending the program. Although most of the documentation covers the use of Visual C++, there are enough Visual Basic examples to get an idea of how things work. For many of the examples, C++ is recommended (especially for the creation of new WebBots, for example). However, due to the speed of application development, Visual Basic has its advantages...

The following article serves as a very brief introduction to FrontPage development using Visual Basic. The example shows how to create a Visual Basic application that links to the FrontPage Editor in order to read and write Metadata to the web page being edited.

Requirements

  • Microsoft FrontPage 98. The SDK (software development kit) is in the SDK folder on the FrontPage 98 CD. The FPDevkit.doc Microsoft Word document in this folder contains essential documentation for using the SDK.
  • Visual Basic (although the samples in the SDK may also be used with Visual C++). This tutorial has been tested in version 4 and above.
  • Some programming knowledge.

The FrontPage SDK is fairly comprehensive, so this article is only brief guide to extending FrontPage through Visual Basic. Additionally, the use of the SDK's Theme Designer has been covered in a previous article from The Complete Webmaster.

Getting started

Start Visual Basic and make a new Standard EXE project. In the project's Form, add a Command Button called Command1, and give it a Caption of Get Metadata. Add a TextBox called Text1 and ensure that its Multiline property is set to True and ScrollBars property set to Vertical. Add a Label next to the Text1 TextBox with the Caption property Page description:.

The form should then look something like this:

The initial Form created by Visual Basic

In Visual Basic, double-click on the Command1 button, and enter the following code for the Command1_Click() event:

'connect to the frontpage editor
Set editor = CreateObject("FrontPage.Editor")

'find out the URL of the page we are editing
Dim pageurl As String
pageurl = editor.vtigettoppageurl

'put the page URL in the form caption
Form1.Caption = pageurl

'initialise some variables
Dim weburl As String
Dim key As String
Dim index As Long
Dim flags As Long

'set description tag
weburl = ""
key = "description"
index = "0"
flags = "0"
Text1.Text = editor.vtigetmetatag(pageurl, weburl, key, index, flags)

'disconnect from the frontpage editor
Set editor = Nothing

Save the Visual Basic project, then run the FrontPage Editor. Ensure that you have a page open in the FrontPage Editor (this page must contain a description meta tag). Once the page is open, run your Visual Basic application. If you then click on the Command Button, you should see that:

  1. The page's URL is displayed in the Form's Caption.

  2. The page's description Metadata is displayed in the TextBox.

An example is shown below:

The Form created by Visual Basic now contains Metadata from the web page!

How it works

The first part of the code connects to the FrontPage Editor using OLE automation. Likewise, the end part of the code disconnects from the Editor.

Once connected to the Editor, there are a number of commands that can be carried out. These are described fully in the SDK. Briefly, editor.vtigettoppageurl retrieves the URL of the topmost open page in the FrontPage Editor. It is this that is displayed in the Form's Caption. editor.vtigetmetatag(pageurl, weburl, key, index, flags) retrieves a certain Meta tag from the topmost document open in the FrontPage Editor. Before it is invoked, the pageurl variable should be set to the currently open page (obtained from using editor.vtigettoppageurl). If the pageurl is specified, weburl should be null. The key variable must contain the name of the Meta tag to be retrieved (in this case description). The index variable is set to 0 if the first instance of the tag should be retrieved (badly written web pages may have duplicates of the same Meta tag!). Finally, flags should be 0 for a standard Meta tag, or 1 for a http-equiv type of tag.

What next?

The FrontPage SDK describes all of the other commands that can be used to automate the FrontPage Editor. These include the vtisetmetatag command that allows you to change existing Metadata in a web page. It is therefore not too difficult to write a Visual Basic application to both read and write Metadata from a given web page. Don't forget that the FrontPage Explorer can also be automated.

The methods described in this tutorial can also be used to create a more ambitious program. For example, I have used the methods described here to create a plug-in for FrontPage that enables me to edit author, reply-to, description, keywords, robots and refresh meta tags in a page without having to resort to the complicated FrontPage Page Properties window. A screenshot of the plug-in is shown below. A similar program could be used to add Dublin Core or RDF Metadata to a web page if you require these in your Internet or Intranet pages.

metadataeditor.gif (10136 bytes)

Finally, the SDK explains how you can add new menu commands to the FrontPage Editor menu (look under the SDK's heading "menu customization"). This is pretty much essential if you want your application to be easily accessible from FrontPage. Unfortunately it involves modifying the Windows registry, so to indemnify myself against nasty accidents, I won't mention how to do it here.

Author: Brett Burridge
Date: 10/08/1998

More articles about FrontPage
More articles by Brett Burridge
Author Biography

write for us about us advertise

Copyright 1997, 1998 A Big Lime. All rights reserved.