The schema library in Word 2003 is where so much is happening for developers. While some end-users will venture into the schema library, most should not care what is in there. A well-architected Word XML solution should keep the inner-workings tidy and transparent.
If you have been reading my blog, you have been getting up to speed on working with WordML, adding schemas to Word, transforming unformatted XML data into well-formed WordML documents, creating XML Expansion Packs, and doing much, much more. In several entries, I showed how I built a reporting solution from Outlook to Word. In so doing, I added a schema to the schema library. Now, I wrote a little VBA code to loop through the XML namespaces in the library and display some basic data. Figure 1 shows the little UI with namespace info:
Figure 1. Small UI to show namespace info
Here is the basic code to deliver the information:
Private Sub UserForm_Initialize()
On Error GoTo Catch
Set Mynamespaces = Application.XMLNamespaces
Dim myNamespace As XMLNamespace
Set myNamespace = Mynamespaces.Item(1)
iCurrentNamespace = 1
CommandButton3.Enabled = False
If Mynamespaces.Count > 1 Then
CommandButton4.Enabled = True
If Err.Number <> 0 Then
MsgBox CStr(Err.Number) + ” ” + Err.Description
Set myNamespace = Nothing
Private Sub ShowInfo(n As XMLNamespace)
Dim s As String
Label1.Caption = n.Alias
s = s + “Location:” + vbCrLf + n.Location + vbCrLf
s = s + “URI: ” + n.URI + vbCrLf
s = s + “Transforms: ” + CStr(n.XSLTransforms.Count)
TextBox1.Text = s
Makes you appreciate .NET more than ever, huh? I cannot describe how strange it feels to go back and code in VBA. It feels like going back to 1983 when I was coding BASIC on a PET 2000 with my friend, Jim Mossey during our senior year in high school. We worked on the only computer our school had. It was in the library. We both had jobs working at the most popular computer store in Minneapolis/St. Paul. It was called “Computer Exercise World.” Yep, you guessed it: we sold computer hardware/software and exercise equipment. The owner wanted to see if the computer thing would take off, so he slowly integrated it with the exercise gear. I used to sell Leading Edge computers. Yeah! Some of you remember those, I am sure. Jim and I were pretty well geeked out, and although we were pretty much in that unheralded group of kids in high school, the unpopular, unathletic, un-dating, etc.- we had this curiously unexpressed notion in the back of our minds that we had our own kind of cool going on. It got us through.
Anyway, so Word 2003 gives you OM access to the XML namespaces and transforms installed with your solutions.
Rock thought for the day: I plan to get a full Marshall stack some day. I want 350 watts of Marshall power.