Erika Ehrli - Adventures with Office Products & Technologies
MSDN & TechNet: Releasing Office, SharePoint, Exchange & Lync Centers and content for developers and IT professionals.

November, 2005

  • Erika Ehrli - Adventures with Office Products & Technologies

    Extracting Microsoft Office Application Properties without automation


    Every file created by a Microsoft Office application supports a set of built-in document properties. In addition, you can add your own custom properties to an Office document either manually or through code. You can use document properties to create, maintain, and track information about an Office document such as when it was created, who the author is, where it is stored, and so on. To get or set the properties you can use automation to extract the Microsoft Office application properties.

    Take a look at the following links for samples:;EN-US;Q303296&

    But what happens if you are working with a Web-based application and you want to avoid the use of automation in a Web server…

    I found a nice workaround to extract Office document properties without using automation. You can use the Dsofile, an in-process ActiveX component that allows you to read and to edit the OLE document properties that are associated with Microsoft Office files, such as the following:
    • Microsoft Excel workbooks
    • Microsoft PowerPoint presentations
    • Microsoft Word documents
    • Microsoft Project projects
    • Microsoft Visio drawings
    • Other files without those Office products installed

    If you are working with a managed application follow the next steps:

    1. Download and install the DSO File control.
    2. Add a reference to InteropDSOfile.dll to your managed Web application.
    3. Create a new Web form and copy the following code.
      <%@ Page Language="C#" %>

      <script runat="server">
      protected void btnLoadFile_Click(object sender, EventArgs e)
      // Define a path to save the file in the server
      string serverTempFilePath Server.MapPath(@"/yourpath/" + FileUpload1.FileName);

      // Create the DSOFile document
      DSOFile.OleDocumentPropertiesClass oleDocument = new DSOFile.OleDocumentPropertiesClass();
      DSOFile.SummaryProperties summaryProperties;


      // Extract the properties
      summaryProperties oleDocument.SummaryProperties;
      tbTitle.Text summaryProperties.Title;
      tbAuthors.Text summaryProperties.Author;
      tbCompany.Text summaryProperties.Company;
      tbNumPages.Text summaryProperties.PageCount.ToString();
      tbWordCount.Text summaryProperties.WordCount.ToString();

      // Close the DSOFile.OleDocumentPropertiesClass

      <html xmlns="">
      <head runat="server">
      <form id="form1" runat="server">
      </strong><br />
      br />
      table border="1">
      <td valign="top">
                              File upload:
      <asp:FileUpload ID="FileUpload1" runat="server" />
      asp:Button ID="btnLoadFile" runat="server" OnClick="btnLoadFile_Click" Text="Load File Properties" /><br />
      <asp:TextBox ID="tbTitle" runat="server"></asp:TextBox> 
      <asp:TextBox ID="tbAuthors" runat="server"></asp:TextBox> 
      <asp:TextBox ID="tbCompany" runat="server"></asp:TextBox> 
                              Number of Pages:
      <asp:TextBox ID="tbNumPages" runat="server"></asp:TextBox></td>
                              Word count:
      <asp:TextBox ID="tbWordCount" runat="server"></asp:TextBox> 

    4. If you run the previous Web form you will get something like this:

    You can also extract custom properties using the DSOFile control.

    Have a peek and enjoy!

  • Erika Ehrli - Adventures with Office Products & Technologies

    How to indent an XML file or document


    Office has a deeper integration with XML technology and developers are always looking for tips and tricks to work with XML documents. Office provides support to work with XML and you might be one of those developers that is programmatically generating Word documents (using WordprocessingML) , Excel spreadsheets (using SpreadsheetML), PowerPoint slides (using PresentationML), or Visio diagrams using (DataDiagrammingML). I think it always comes handy to have a list of tips and tricks to work with XML, and today I will share with you three simple ways of indenting an XML file/document.

    Indenting XML files might sound as one of those netpick or nice-to-have enhancements that you don’t really need when you are working with XML. However, lots of applications and tools generate programmatically XML files and it always comes handy to open a nice and readable indented XML file instead of a “how can I edit this!” single line of eternal XML elements.

    For managed applications:

    • If you are generating XML files using and XmlTextWriter, you just need to do the following:

      Dim writer as XmlTextWriter = new XmlTextWriter("data.xml",nothing)

      XmlTextWriter writer = new XmlTextWriter("data.xml",null);
      writer.Formatting Formatting.Indented;
    • If you are generating XML files/documents using DOM (XmlDocument) , you can add an XmlTextWriter to indent the code and you will be done:

      Dim doc as XmlDocument = new XmlDocument()
      ' Save the document to a file and auto-indent the output.
      Dim writer as XmlTextWriter = new XmlTextWriter("data.xml",nothing)

      XmlDocument doc = new XmlDocument();
      // Save the document to a file and auto-indent the output.
      XmlTextWriter writer = new XmlTextWriter("data.xml",null);
      writer.Formatting Formatting.Indented;

    For any platform:

    • If you are generating XML files using an XSL transform file, you just need to add a simple line to your XSL file.

      <?xml version="1.0"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="">
      <xsl:output method="xml" omit-xml-declaration="no" indent="yes" encoding="US-ASCII"/>

    Happy Office XML programming!

  • Erika Ehrli - Adventures with Office Products & Technologies

    Visual Studio 2005 Launch and my favorite features


    Today is a great day for Microsoft: Visual Studio 2005, SQL Server 2005, and Biztalk were launched. I want to share with you the list of my favorite Visual Studio 2005 features and some pointers to articles, videos, code samples, and sites where you can find further information:

    1. Visual Studio Tools for Office: You can extend Office applications and create custom business solutions using Visual Studio Tools for Office (VSTO 2005). I have been playing with VSTO and I find fascinating how you can drag-and-drop Windows forms controls to Excel Worksheets and Word documents. You can later add some code-behind business logic and connectivity to data. I also find fascinating that you can create custom Outlook solutions thanks to the support provided by VSTO for building application-level add-ins using managed code with Outlook. I strongly recommend you to read a great article written by Janet Robinson: What’s new in Visual Studio 2005 Tools for Office. You should also see the redesigned Visual Studio Tools for Office Developer Portal at the Office Developer Center.
    2. ASP.NET 2.0: I am very excited about this technology. I have been working with ASP.NET 2.0 all this year and I find fascinating how you can create Web-based applications in such an easy way and in less time than you can imagine. There are lots of enhancements and features that I can talk about, but I recommend you to play around with MasterPages, Themes, and Skins to create the look-and-feel or your sites. Experiment with DataSource controls to see how easy it is to bind data to your server controls without writing code related with ADO.NET read about the Web part framework, you will be able to create custom Web parts and export them to SharePoint. Also, the next version of SharePoint uses a lot of   ASP.NET 2.0 features, so if you are a SharePoint developer, start learning ASP.NET 2.0. Check out this Visual Web developer training videos series.
    3. Class Designer: I was really excited when I saw this. I used to generate UML Class diagrams using the Reverse Engineering feature that shipped with Everett. I was happy then, but you should see this new Class Diagrams, they are perfect. I like that you can create them really fast and with little customization, it's a great way to work with your Object Models and you can save them as images and add them to your documentation.
    4. Intellisense: There are so many assemblies now that you can’t possibly remember all the interfaces, classes, and then properties, methods, events, and more. I love that code files, even Web forms have Intellisense now.
    5. Visual Data Designer: You can connect to your SQL Server database and create tables, relationships, views, and stored procedures in less time and using the same environment where you write your application code. I love that you can drag-and-drop a table from the Visual Data Designer to a form and then Visual Studio 2005 creates for you a GridView and a SQLDataSource connection that allow you to select, insert, delete, and update data to the table. You don’t even need to know ADO.NET to connect your managed applications to a data store. Try it!
    6. Code snippets: You might need to reuse code over and over, so now you can store it inside Visual Studio and forget about looking for old code in hard drives and CDs. I love this!
    7. Debugging: The debugging experience is way much better. When you are debugging you can mouse over an object and you will see a context window with all the information related to the object without typing commands in the Command Window. You can even see the details of exceptions.

    Watch this video:

    You can find more videos here: Absolute Beginner’s Video Series

    I know that when someone from Microsoft states that a product is good, it sounds like marketing. But I have to tell you that I am being honest and talking only as a developer that is quite excited to experience and work with Visual Studio 2005. The best you can do is to give it a try.



  • Erika Ehrli - Adventures with Office Products & Technologies

    How to: Uploading a File to a SharePoint Library Site from a Local Folder


    I am currently developing an application that will help my team (Office Developer Documents) to manage all the metadata associated with the publishing process in MSDN. The name of the tool is Rawhide and it’s a Web-based application. I am really excited of developing this tool because I am working with Whidbey, ASP.NET 2.0, SQL Server, Windows Sharepoint Services, and a cool set Office development features. Soon I will start adding Office “12” enhancements such as Excel Services and Windows Sharepoint Services “v3”. I can’t wait!

    I am learning a lot from my peers about how interesting it is to publish content in MSDN and I hope this tool will improve our working experience and become a great source of code snippets that I can share with the community.

    Today I was reading the newsgroups and I was looking at lots of posts where developers are looking for code that will help to upload programmatically files to a SharePoint library. I was surprised to see that there are lots of developers struggling with this issue. I am too :). One of Rawhide’s features is to submit our articles, code samples, and art to a SharePoint Library.

    I found two great articles that are helping me out to accomplish my mission. I know there are many ways of doing that, but this is the recommended one by Microsoft and I love it because it has just what I needed and it has code in C# and VB.NET:

    Uploading a File to a SharePoint Site from a Local Folder

    I also found this page that has all the information I need to work with the SPFileClass.

    And finally, I found this interesting blog entry at Bill Simser’s blog where he talks about the Syncronization of Office Document Properties with WSS Document Libraries. I haven't tested this yet, but apparently, if you create the following properties in a Sharepoint library or list:

    Hyperlink base

    "The MS/Office documents that are upload inherit such corresponding custom MS/Office properties : "


    As soon as I complete my "upload files to SharePoint" features in Rawhide, I will keep you posted with the outcome.

  • Erika Ehrli - Adventures with Office Products & Technologies

    Microsoft announces Windows Live™ and Microsoft® Office Live


    Technology and the Internet created an information revolution that has changed our lives. Today, Bill Gates announced a new set of internet-based services that change the delivery and business models for software. Microsoft has been quite successful with X-Box live and I can tell you that I have seen that having a “live” game completely modifies the experience. So I find quite exciting that Windows Live™ and Microsoft® Office Live were announced.

    Windows Live™ is a set of personal Internet-based services and software that you can subscribe to get the information and resources that YOU want, for example email, messenger, your favorites, and more. What is the advantage? For example, you no longer will need to transfer your favorites (I hate that) from machine to machine.  Subscribe and take a look at some Windows Live services here:

    Microsoft® Office Live is a new set of Internet-based services and software that will allow people and organizations to subscribe to specific services that integrate with Microsoft Office programs including Microsoft Outlook®, Microsoft Excel®, Microsoft Office Live Meeting and Microsoft Office Small Business Edition. Subscribe and take a look at some Microsoft® Office Live services here:

    Office Live has different offerings:

    • Office Live Basics: “To help small businesses to establish an online Internet presence including a domain name, a Web site with 30 MB of storage, and five Web e-mail accounts at no charge through an advertising-supported model.”
    • Set of subscription-based services: “To provide more than 20 business applications to help automate daily business tasks such as project management, sales and collateral management, customer management, expense reports, time and billing management, and secure internal and external collaboration. Built on Windows SharePoint® Services, these applications can be customized and extended to specific customer needs by an extensive Microsoft partner ecosystem.”

    So depending on your needs you can choose the best services and over time, both Windows Live and Office Live services will expand and provide new services that you can subscribe to.

Page 1 of 1 (5 items)