| the complete webmaster | ||||
| tutorials | reviews | reference | ||
|
Extending FrontPage using the SDK and Visual BasicIntroductionAlthough 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
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 startedStart 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:
In Visual Basic, double-click on the Command1 button, and enter the following code for the Command1_Click() event: 'connect to the frontpage editor 'disconnect from the frontpage editor 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:
An example is shown below:
How it worksThe 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. 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 More articles about FrontPage |
| write for us | about us | advertise |
Copyright 1997, 1998 A Big Lime. All rights reserved.