SharePoint Development from a Documentation Perspective

Andrew May

April, 2005

  • Andrew May's WebLog

    Creating Web Pages with the Publisher Object Model


    You know, sometimes it's the obvious things you miss. I was meeting a few days ago with the programmer-writer who is taking over writing Publisher developer help for the next release. I was giving him a guided tour of the Publisher object model, and I thought "you know, this should really be written down somewhere."


    I had written an entire series for beginning developers on how to get started with the Publisher object model. But somehow I had never gotten around to writing an article that contained the things an experienced programmer would want to know if they were coming to the Publisher object model—and perhaps Publisher as a whole—for the first time.

    So I've decided to see if I can't write a series of entries here that address the issues an experienced programmer would encounter as they ramp up on the Publisher object model. With any luck, I'll be able to roll them into an actual article somewhere down the road.

    Here's the first of those topics. It's a snappy little number I like to call:

    Creating Web Pages with the Publisher Object Model

    You can create web pages with Publisher 2003. In Publisher 2003, there are two types of publications: print publications, and web publications. A web publication represents a group of web pages. Each publication page corresponds to a single web page. You create and design the pages within Publisher as you would a print publication. When you have finished designing your web publication, you publish the file to the web.

    You can also publish a print publication to the web; however, the appearance of the Web pages may differ from the printed publication.

    When Publisher publishes a publication to the web, it creates an HTML representation of each page in the publication, and then saves those HTML files, along with any necessary supporting files, to the specified URL location.

    The HTML files that Publisher publishes have no link to the original Publisher file used to generate them. If you later need to make changes to the web pages, do not edit them directly. Rather, make your changes to the original Publisher web publication, and then re-publish the file to the same URL location. Changes made to the HTML directly are not propagated back to the original web publication; indeed, if you do edit the HTML, and later re-publish the Publisher file, your changes are overwritten.

    By default, Publisher treats the first page in the publication as the initial page in your web site. By default, Publisher saves the HTML file representing the first publication page as 'index.htm'. Publisher saves the HTML pages for any other publication pages, as well as any support files (such as image files), in a folder called 'index_file', located in the same directory as the index file. If you do not specify the file name for an HTML file, Publisher generates a name for it automatically.

    To determine if a publication is a print or web publication, use the Document.PublicationType property. To convert a print publication to a web publication, or vice versa, use the Document.ConvertPublicationType method. Note that this overwrites the previous version of the file.

    To publish a file to the web, use the Document.SaveAs method. For the Format parameter, specify pbFileHTMLFiltered. For the FileName parameter, specify the URL location to which you want to publish the file. This corresponds to choosing the Publish to the Web command from the File menu. Note that the .htm file extension is automatically added to the value of the Filename parameter if the value of the Format parameter is pbFileHTMLFiltered.

    This example saves the active Web publication as a set of filtered HTML pages and supporting files. In this example, Publisher names the HTML file representing the first publication page after the original web publication name. (Note that URLPath must be replaced with a valid file path for this example to work.)

    With ActiveDocument

        .SaveAs Filename:="URLPath" & .Name, Format:=pbFileHTMLFiltered

    End With

    Note   The pbFilePublicationHTML value of the Format parameter represent an HTML file format available in Publisher 2002 that enabled re-importation of the HTML Publisher generated. Because of the resulting large file size, however, this file format has been deprecated and should not be used.

    If you specify pbFileWebArchive for the Format parameter, Publisher generates an .mht file. An .mht file is an HTML file that has all of its support files, such as images and other files, embedded in it.

    If you later make changes to the web publication and need to re-publish it, simply use the SaveAs method with the same file path specified. This overwrites the existing HTML files; no warning is given.

    To generate a preview of a web publication, use the Document.WebPreview method. This method generates a local HTML copy of the publication, and displays it in the users default browser. The Web preview opens with the active page displayed. Preview Web pages are generated for each page in the publication. However, if the publication is a print publication or otherwise lacks a navigation bar, there may be no way to navigate to those pages.

    The following example sets the active page of the publication and generates a Web preview of the publication.

    With ActiveDocument

        .ActiveView.ActivePage = .Pages(2)


    End With

    Publisher 2003 includes pre-defined web navigation bars that you can include in your Web publication. For more information on how to use web navigation bars programmatically, see Adding Navigation Bars to Web Publications in Microsoft Office Publisher 2003.

    To specify settings for the web publications you create, use the WebOptions object. This object contains properties that represent settings that newly created Web publication inherit, such as encoding and font options. When you modify any of these settings, any Web publications you create inherit the modified properties.

    For example, if you need to re-publish a large Web publication, you might want to set the EnableIncrementalUpload to True. This specifies that only changes made to a publication will be uploaded to the Web server when published, rather than the entire publication. The EnableIncrementalUpload property applies only to Web publications that have already been published to a Web server. If a Web publication has not already been published to a Web server, the entire publication will be published to the server during the initial publishing process, regardless of whether the EnableIncrementalUpload property is set to True.

    The WebOptions object settings are application-level settings specific to each user.

    To specify web properties for a specific page, use the WebPageOptions object. This object contains properties that represent web characteristics of the specified publication page, such as background sound, page description, and whether to include the page on new web navigation bars. To specify a file name for the HTML file generated from a publication page, use the WebPageOptions.PublishFileName property. As mentioned earlier, specifying a file name for a Web page is optional. When a publication is saved as filtered HTML, Publisher automatically generates file names for any Web page that does not have a file name specified. User defined file names are only used when a publication is saved as filtered HTML. File names must be specified without a file extension.

  • Andrew May's WebLog

    Windows Server 2003: Screen Resolution Weirdness


    Here's the second of two tips my manager shared with me concerning installing Windows Server 2003.

    The first tip dealt with being unable to connect to the Internet.

    This tip deals with screen resolution, and has a very strange workaround.

    After installing WS2003, he had a problem with his screen resolution: he could only set it as far as 256 colors, and 1024 by 768 pixels. He spent a fair amount of time talking to the Help Desk, and messing with the video adapters and drivers, to no avail.

    (To see what resolutions your adapter supports: On the Start menu, point to Settings and click Control Panel, and then click. the Display icon. On the Settings tab, click the Advanced button. On the Adapter tab, click List All Modes. Windows displays a list of the resolutions which the adapter you're using supports.)

    Finally, here's the workaround he stumbled on:

    1.      On the Start menu, point to Settings and click Control Panel.

    2.      Double-click Regional and Language Options.

    3.      On the Languages tab, select the Install files for East Asian languages, and then click OK.

    4.      Follow the steps to install the East Asian language support and reboot your system.

    And that did the trick.

    Someone else suggested that perhaps his adapter was too new to be included in the WS2003 distribution, so it used a generic driver which was replaced by the language upgrade. If anyone's got any other theories, I'd love to hear them.

    In any case, now his screen resolution is a comfortable 32-bit color quality and 1600 by 1200 pixels.

    And he can write things like 度主ありが十ございます

  • Andrew May's WebLog

    Windows Server 2003: Unable to Connect to the Internet


    A few months back, when I first moved over to working on Windows SharePoint Services, I decided to turn one of my work computers into a WSS box. I later decided to install a Virtual PC profile on the machine instead. But my new manager forwarded me a few tips concerning issues he'd run into when he initially installed Windows Server 2003. These were things that the Help Desk was, well, less than helpful in fixing.

    So I thought I'd put them out here, in case someone with the same problems runs across them.

    Here's the first:

    Once he had Windows Server 2003 installed, he couldn't connect to the Internet at all. What's more, anytime he browsed to an intranet site, he was prompted for his username and password for each site the master page was linking to.

    Turns out he needed to adjust his internet security configuration. Here's how:

    1.      On the Start menu, point to Settings and click Control Panel.

    2.      Double-click Add or Remove Programs.

    3.      Click Add/Remove Windows Components.

    4.      In the Windows Components Wizard, de-select Internet Explorer Enhanced Security Configuration and then click Next.

  • Andrew May's WebLog

    John Durant Moves On


    If you've read his blog lately, or visited the Office Developer Center front page, then you know that John Durant has relinquished the reins at the ODC, in order to become a program manager for Visual Studio Tools for Office.

    I've worked with John for the better part of two years now, and count myself lucky to have done so. John has been a huge influence on my development as an Office programmer. He was always available for a quick tutoring session on the programming topic of the day, and his enthusiasm for diving into new APIs and finding out what made them tick was great encouragement for someone like me, for whom any API was a new API. His faith that I could become a successful Office programmer-writer is a large part of the reason I am a successful Office programmer-writer.

    So I wanted to take a moment and add my personal thanks to the chorus of praise he's been getting this week, and to wish him the best in his new role.

    Below is a sketch I did of John in his bike gear, for the ODC portal page. We were waiting to run it this spring, so we never got to use it. (Yes, I know that John bikes year 'round in any weather. But we figured we'd wait to use it at a time of the year most sane people equate with biking-ride weather.)

    Ride on, brother.

  • Andrew May's WebLog

    Rock Thought for the Day: Garbage


    At the risk of further poaching on John Durant's turf, it turns out I have another Rock Thought of the Day® to share:

    Garbage's new CD, Bleed Like Me, is out today. At first listen, you'd never know the band's been gone for the past five years. It sounds much like business as usual. And that may be part of the problem: four CD's in, I had hoped to hear the band move beyond the territory they staked out with their first three efforts. This time around, they've gone for a rougher sound: the guitars are louder, the song hooks buried, and Shirley Manson's vocals filtered in many places until they sound like she's singing through a drive-thru window speaker. But for all the surface changes, the music doesn't really incorporate any new influences, present any new ideas, or ever take any unexpected turns. (As much as I like the title track, it takes you about a verse and a half to realize they're doing an intentional riff on Lou Reed's Walk on the Wild Side.) Granted, I've listened to the CD a grand total of two times, so I reserve the right to change my opinion. But at first blush, there's not much here to reach beyond the die-hard Garbage fan.

    Money For Nothing

    I was actually supposed to see Garbage last Friday here in Seattle, at the opening show of their American tour. I was jazzed, to say the least: I've seen them twice before, and thoroughly enjoyed both shows. Add to that the fact that we'd be hearing their new material before the CD was even released, and I was looking forward to a special night.

    Unfortunately, the band, fresh from a European promotional tour, got sick and had to cancel at the last minute.

    Which is understandable; it happens. And at forty dollars a ticket, you don't really want to see a sick band limp through a show, do you?

    What's not so understandable, is the fact that no one knew anything about whether the show was cancelled, postponed, or happening the next night. We were originally told by the Paramount staff that the show might be moved to Saturday night, and to call TicketMaster or listen to The End, which promoted the show. Except TicketMaster refused to confirm or deny anything. And the DJ on The End couldn't find out any information either, even though he'd been inundated with calls from people like us all day Saturday. (The Paramount ticket office is open bankers' hours during the week, so no help there.)

    Finally, late Sunday, TicketMaster sent out an email saying the show was cancelled and that you could return your tickets for a refund—minus 3.35 USD per ticket, which TicketMaster decided it was keeping.

    Now, it's bad enough that TicketMaster's "service fees" amounted to a 28% tax on the tickets to begin with (30.50 USD per ticket, plus 8.50 USD per ticket service fees). But to keep 3.35 USD per head for a show that didn't even happen? When did that become acceptable? The Paramount has 2807 seats; so, for the sold-out Garbage show, TicketMaster pocketed 9403.45 USD—nearly ten grand from Garbage fans who got exactly nothing in return.

    For my little party of 4, we ended up donating 13 USD to TicketMaster—just about the cost of a new Garbage CD.

  • Andrew May's WebLog

    OneNote: Importing Pages that Vanish


    Here's an interesting little "gotcha" that was found by Saul Candib, the programmer-writer who is taking over documenting OneNote programming features, now that I've moved over to SharePoint.

    Using my article Importing Content into OneNote 2003 SP1 as a guide, Saul wrote some code that imported content into OneNote. The code seemed to work fine: OneNote would create the page the user specified, and import the specified content no problem.

    Except, once you closed OneNote, when you opened it again the page and all its contents were gone.

    Turns out Saul wasn't specifying the '.one' file extension for the page. So the import routine worked perfectly; OneNote created the page and imported the content. You could even go in and add or edit the content on the new page, whatever you wanted. OneNote actually was saving the page in the My Notebooks folder, but without an extension. So the next time you launched OneNote, it saw the imported page as an unknown file and so didn't load it.

    All of this was news to me. In my XML examples in the article, I used the .one file extension. For example:

    <PlaceObjects pagePath="MSN Instant Messenger\" pageGuid="{8FDD3C41-5BB5-4595-B019-7E7E9BC9D38E}">

    But I never specifically called out that this was a requirement; to be honest, I don’t remember if I ever realized it was a requirement. I certainly never experimented with what happened if I didn't specify the file extension.

    What's worse, in my example in the article, I wrote a really basic application that let the user enter the name of the page they wanted to create. But I didn't write any code that checked the specified page name to make sure it contained the file extension, or add the extension if the page name didn't. Shame on me.

Page 1 of 1 (6 items)