Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Open XML SDK - Word 2007 Uri Issue

Open XML SDK - Word 2007 Uri Issue

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpxmlquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ed Hill _5_
    wrote on last edited by
    #1

    I've just lost a day and a half of my working life trying to track down a bug which was causing word documents i am changing to include a mail merge source to error when opened in word 2007. The documents work fine in word 2010. After an awful lot of digging, I've tracked the issue down to the URI for the mdb file that is the data source for the merge. My non working in 2007 code was as follows:

    using (var docx = WordProcessingDocument.Open(filePath, true))
    {
    FileInfo mdbFile = FileHelper.GetResourceFile("Merge.mdb");
    Uri mdbUri = new Uri(mdbFile.FullName, UriKind.Absolute);

    var settings = DocHelper.GetOrCreateSettingsPart(document);
    
    settings.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/mailMergeSource", mdbUri, id1);
    

    }

    After an awful lot of checking i found that the relationship file was recording the uri without a leading "file:///", some more looking into this it appears that the openXML SDK is writing out the OrigionalString. The change i had to make to my code for it to work was as follows:

    Uri mdbUri = new Uri("file:///" + mdbFile.FullName, UriKind.Absolute);
    

    I guess my question is, was i doing something wrong when working with the Uri or is this something that the SDK is not getting right. Additionally i really hope it is not a bug that was found, and fixed in Office 2010 by working with the Uri missing the "file:///" prefix insted of changing the SDK to write out Uri.ToString();

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups