Extending the Web with Office 97 Developer Edition and Visual InterDev Now the developer community has a powerful duo for developing Web sites based on Microsoft® Office documents-Microsoft Office 97 Developer Edition (ODE) and Microsoft Visual InterDev™. ODE gives developers using Office 97 in-depth documentation and advanced functionality in areas that have special interest to them. Many of ODE's features will also appeal to Web developers. Visual InterDev, a core component in Microsoft Visual Studio™ 97, targets team Web site development, and at least some of the content authors and even database contributors are likely to be Microsoft Office 97 users. Many of these will be power users and developers using ODE. This article introduces you to both ODE and Visual InterDev. I'll start off with a brief overview of ODE, then take a more detailed look at two of its new capabilities, hyperlink programming and the Web Browser ActiveX™ control. I'll focus on hyperlink programming for Microsoft Excel, PowerPoint, and Word, in particular. Then, I'll show you how to use the Web Browser ActiveX control to bring Web connectivity to custom Office applications. My Visual InterDev discussion focuses on how to use the product with the ODE. The sample applications reveal how to integrate Visual InterDev with Office 97 for Web site development. ODE Overview The ODE provides a broad range of tools to support the needs of custom application developers. Some of these include software available only with the ODE (and not Office 97 Professional Edition), and manuals and whitepapers distributed along with the ODE. By using the documentation along with the software tools, you can build more functionality into Office 97 custom applications. The Microsoft Office 97 Visual Basic Programmers Guide ships with the ODE. This handy manual introduces the basics of Visual Basic® for Applications programming and shows you how to apply that knowledge to the object model of each Office component. It also presents advanced topics such as programming the Office Assistant, designing custom menus and toolbars, ODBCDirect, and error trapping and debugging. The manual offers a rich selection of code segments and procedures for you to try. It presents Visual Basic for Applications equally well for use with Microsoft Access, Microsoft Excel, PowerPoint®, and Word. The second manual in the ODE is Building Applications with Microsoft Access 97. This manual includes more detail on Visual Basic for Applications coding and debugging specific to the Access environment. Other important topics in the manual include security, multiuser development, client/server application design, database replication, and Internet and intranet development. A major attraction of both these manuals is that they're available in hard copy, which makes them easy to lug around without worrying about battery life. You can also highlight and underline as your needs dictate. In addition, I discovered Building Applications with Microsoft Access 97 available for viewing with a browser on the ValuPack that ships with Office 97 Professional Edition. Since ODE owners get this CD, they have their choice of working with the manual in either format. Two additional ODE-only whitepapers further enable developers to take advantage of the Office 97 platform. The Replication Manager whitepaper provides an excellent introduction to this important topic while it describes the enhancements to replication with Microsoft Access 97. You can control replication directly or through Data Access Objects (DAO) from Microsoft Access, Visual Basic, Microsoft Excel, Visual C++®, and Project 97. Developers can also set up replication schemas with the new version of Replication Manager that ships exclusively with the ODE. Office 97 enhances database replication over Office 95 in two areas. First, the new Jet engine performs partial replication. This can dramatically speed up performance for mobile workers and remote sites that don't need to synchronize with a whole database. Second, Jet 3.5 can perform replication over a company intranet or the Internet, thus lowering the communication costs for synchronizing data. A Partial Replica Wizard is available free of charge at http://www.microsoft.com/accessdev/freesoft.htm. The second whitepaper introduces the topic of source code control in Microsoft Access 97-an upgrade of the database that targets teams of developers. Source code control tracks changes to and versions of database objects so developers can track the history of database objects and rollback changes to objects (see Figure 1). Even independent developers can benefit from the rollback feature because it lets a developer recover an earlier version of a database object before some program bug corrupted its performance. The checkin and checkout features make it easy for one developer to pass design changes on to other team members. Integrated source code control is available only to ODE users who own a separate source control package. The Microsoft ODE Tools Sampler is a subset of Microsoft Developer Network (MSDN) material that targets the needs of Office developers. After installing the CD, you will be able to browse and search for categories of materials including backgrounders and whitepapers, developer-oriented product documentation, stories from leading periodicals, sample code, and KnowledgeBase articles. Because this product is released concurrently with Office 97, the material refers to earlier versions of Office, which still comes in handy if you need to maintain some older Office applications as you develop new ones with Office 97. The new Setup Wizard is a model of simplicity while permitting fine-grained control over how your custom applications will load. The custom setup program it generates can load one or more .mdb files comprising your application, ActiveX controls, the runtime version of Microsoft Access 97, and other supporting files for your custom application. The Microsoft Access 97 runtime version is royalty free, but it's only available as part of the ODE. The enhanced Help Workshop for Windows® 95 adds a graphical user interface for constructing Access help files. It runs with Windows 95 as well as Windows NT® versions 3.51 or 4.0. Use the Win32® API Viewer to ease the process for incorporating API declarations in your custom applications. The Viewer facilitates searching the collection of Win32 interfaces so that you can copy one or more to the clipboard. From there, you can easily insert the interfaces in your custom application. Hyperlink Programming Hyperlinks in Office 97 can point to a URL, another Office file, or another part of the same file. The exact object to which a hyperlink can jump varies by component. For instance, Word permits hyperlinks to bookmarks, while PowerPoint allows jumps to slides. With Microsoft Excel, a hyperlink can reference a worksheet or a range of worksheet cells. Access permits any database object to be a hyperlink target. Using the Hyperlinks collection, you can add and follow hyperlinks in Microsoft Excel, PowerPoint, and Word. (Access 97, however, does not rely on this collection as the basis for programming hyperlinks.) To insert a hyperlink under programmatic control in Microsoft Excel, PowerPoint, or Word, you must specify a hyperlink address and anchor it in an object associated with the hyperlink. PowerPoint objects can have two hyperlinks associated with them: one that activates when the mouse moves over them and another that's invoked by a mouse click. Or you can add a label or graphic to mark the hyperlink. This is especially convenient when you want a user to click a label or graphic to transfer control to the hyperlink address (see MIND, April 1997 for more information on hyperlink programming in Access). Figure 2 shows a form designed in Microsoft Excel that lets users jump to any one of a preselected set of hyperlinks. Clicking the combo box opens the list of hyperlinks from which a user can choose. A click to the command button with the caption Jump then causes the browser to open the selected URL. When a user clicks the back button on the URL, the browser closes and control returns to Microsoft Excel. The AddLink procedure adds hyperlinks to the second worksheet in the active workbook. The code inserts four hyperlinks in cells A1 through A4. I attached this public procedure to Sheet 1 to demonstrate the flexibility with which you can deploy procedures throughout an application. Public Sub AddLink() Dim wrk As Worksheet Set wrk = ActiveWorkbook.Sheets(2) wrk.Hyperlinks.Add Address:= _ "http://www.microsoft.com/", _ Anchor:=wrk.Range("A1" wrk.Range("A1").NumberFormat = ";;;" wrk.Hyperlinks.Add Address:= _ "http://www.microsoft.com/mind/", _ Anchor:=wrk.Range("A2") wrk.Range("A2").NumberFormat = ";;;" wrk.Hyperlinks.Add Address:= _ "http://www.microsoft.com/officedev/", _ Anchor:=wrk.Range("A3") wrk.Range("A3").NumberFormat = ";;;" wrk.Hyperlinks.Add Address:= _ "http://www.microsoft.com/vinterdev/", _ Anchor:=wrk.Range("A4") wrk.Range("A4").NumberFormat = ";;;" End Sub The procedure starts by declaring a reference for a worksheet. Next, it sets the reference to the second worksheet. Then, it uses the Add method of the Hyperlinks collection to attach a hyperlink address in cell A1. Next, the code sets the NumberFormat property of the range equal to ";;;". This hides the cell's contents. These last two lines are repeated for cells A2 through A4. I invoke the AddLink procedure from an Auto_Open Visual Basic for Applications script in Module 1 of the Microsoft Excel project: Sub Auto_Open() Sheet1.AddLink HyperlinkJumps.Show End Sub The Auto_Open script performs one other function-it opens the form with the hyperlinks and the command button. It does this by applying the Show method to the form named HyperlinkJumps. A private event procedure (UserForm_Initialize) behind the HyperlinkJumps form fires as it opens. The procedure populates the combo box with the AddItem method. It adds hyperlinks from the second sheet to the combo box. The event procedure uses the For Each...Next statement to loop through all the hyperlinks on the sheet. Private Sub UserForm_Initialize() Dim hypCurrent As Hyperlink For Each hypCurrent In ActiveWorkbook.Sheets(2).Hyperlinks cboMyHyperlinks.AddItem hypCurrent.Address Next End Sub The final procedure for this application fires when a user clicks the command button with the caption Jump (cmdJump_Click). The procedure applies the Follow method to a hyperlink in the collection on the second worksheet. The index of the selected item from the combo box serves as a guide to picking a hyperlink. The code adds one to the combo box index since it starts at zero, but the hyperlinks in a collection start with the number one. Private Sub cmdJump_Click() ActiveWorkbook.Sheets(2).Hyperlinks _ (cboMyHyperlinks.ListIndex + 1).Follow End Sub