Patrick\’s Bytes

31, May 2008

SharePoint On Vista! Another good reason for dev to use Vista?

Filed under: Sharepoint,Windows Vista — patrickyong @ 9:13 pm

Yup, you read it right, SharePoint can runs on Windows Vista thanks to Bamboo Solution’s setup helper here. Many thanks to Jonas for commenting it on my blog post.

Go check it out today, there is a walkthrough with screenshots as well. It shows Windows SharePoint Services but I guess it might work for MOSS 2007 as well. 🙂

Advertisements

30, May 2008

What’s up? Going to Penang next week.

Filed under: .NET Programming,Visual Studio 2008 — patrickyong @ 2:46 pm

I am out of KL for this week and will be running some workshops and talks at Penang.

This coming Monday and Tuesday I will conduct a Getting Start with .NET programming workshop at MCSB Training Center at Island Plaza. With the help of my pal Ervin Loh, he updated the content of the workshop to use latest features from .NET Framework 3.5 and hands on labs are using Visual Studio 2008. My colleague Rahimah will also be running similar workshop at Cyberjaya at the same place.

image

After that on next Thursday I will do a What’s new with Visual Studio 2008 talk at Penang Skills Development Center, expect something cool to be demo.

image

28, May 2008

Windows 7 demoed

Filed under: Windows 7 — patrickyong @ 4:08 pm

Watch Bill Gates and Steve Ballmer talked about Windows 7. If you don’t know what is Windows 7, just FYI, XP is Windows 5.1 and Vista is Windows 6 then you will get the picture.

image image

I believe Windows 7 is years away because this demo is still using Windows Vista look and feel with multi touch technology inside. Interesting part of this demo would be:

1. The multi touch demo is done using existing Tablet PC in the market, which I don’t see additional hardware mounted on it.

2. Multi touch is done on some WPF applications, especially the familiar piano, this could mean that WPF with all their bells and whistles will also get multi touch enabled which make it more fun and cool !!

3. Multi touch capability demos and clients are still important and they will continue to evolved. There wouldn’t just a SaaS world with client OS being just cheap commodity.

Check out the videos here.

http://d6.allthingsd.com/20080527/gates-ballmer-video-part-1/

http://d6.allthingsd.com/20080527/video-bill-gates-and-steve-ballmer-highlight-reel-part-two/

http://www.engadget.com/2008/05/27/microsoft-shows-off-snippet-of-windows-7-at-d6-reveals-multi/

27, May 2008

Replace content of <w:t> element inside Content Controls with data bound value from Custom XML part

Filed under: LINQ,OpenXML,Word — patrickyong @ 4:47 pm

In my previous post I discovered that Content Controls in WordprocessingML files which has data binding to a CustomXML part will not render properly. However, this ONLY apply if you programmatically replaces the CustomXML part but never modify the value of <w:t> within the <w:sdt> element just like in this Eric White’s video on YouTube or as per mentioned in the book [Pro SharePoint Solution Development] in Chapter 7 .

To make things clearer, lets look at the screen shots below. For a Word 2007 document with CustomXML data bound(AND also with the CustomXML modified programmatically), below is what it looks like by default when you open it with Office 2003 (or XP and 2000), the data does not appear (below).

image

Even though you see there is no problem when open it up with Office 2007 (below)

image

This is because the Compatibility Pack for Office 2007 File Format does not render the value data bound inside the <w:databinding> element but instead its take the value in <w:t> element, shown below:

<w:sdt>
– <w:sdtPr>
<w:dataBinding w:xpath=”/root[1]/name[1]” w:storeItemID=”{b6aa39be-c6d5-40ca-a66e-93dbd069104f}” />
  <w:id w:val=”3411243″ />
– <w:placeholder>
  <w:docPart w:val=”DefaultPlaceholder_22675703″ />
  </w:placeholder>
  <w:showingPlcHdr />
  <w:text />
  </w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”006D15FD” w:rsidRDefault=”00F43988″>
– <w:r w:rsidRPr=”00583873″>
– <w:rPr>
  <w:rStyle w:val=”PlaceholderText” />
  </w:rPr>
<w:t>Click here to enter text.</w:t>
  </w:r>
  </w:p>
  </w:sdtContent>
  </w:sdt>

So I created a generic project using the latest OpenXML SDK (April 08 CTP) and together with LINQ to XML to modify the content within <w:t> element with the value from the CustomXML part. You can download my full source code here, but basically this is how my solution works:

XNamespace w = @”http://schemas.openxmlformats.org/wordprocessingml/2006/main”;

        public void Convert(string fileName)
        {
            using (var wordDoc = WordprocessingDocument.Open(fileName, true))
            {
                var mainPart = wordDoc.MainDocumentPart;

                XmlReader reader;

                reader = XmlReader.Create(mainPart.GetStream(FileMode.Open, FileAccess.Read));

                XDocument mainXml = XDocument.Load(reader);

                string xpath;
                XElement t;
                var bindings = mainXml.Descendants(w + “dataBinding”);

This is where the magic works, grab XPath attribute value from all the <w:databinding> elements and then replace it into <w:t> element using GetValueFromCustomXmlParts method (details do refer my source code)

                foreach (XElement binding in bindings)
                {
                    xpath = binding.Attribute(w + “xpath”).Value.ToString();

                    t = binding.Parent.Parent.Descendants(w + “t”).First();
                    string textValue = GetValueFromCustomXmlParts(mainPart.CustomXmlParts, xpath, myns);

                    t.ReplaceNodes(textValue);

                }

                XmlDocument temp = new XmlDocument();
                temp.Load(mainXml.CreateReader());
                temp.Save(wordDoc.MainDocumentPart.GetStream(FileMode.Create, FileAccess.Write));
            }
        }

After that the Word 2007 document can be opened in Office 2003 and data are rendered successfully. This solution also works in other none-MS Office productivity suites such as ThinkOffice and WordPerfect.

image

Disclamer: This is just a quick fix or rather a proof of concept on how to solve the <w:databinding> element problem on a simple Word 2007 document, there are  many situations (or more complex document layout) I haven’t tested the solution on. Do download my solution at your own risk. If you bump into problems do let me know, but my help will only be on best effort basis.

By the way, here is Eric’s video on the new OpenXML SDK

[YouTube=http://www.youtube.com/watch?v=t_FYHd234ng]
YouTube – Open XML SDK demo and road map

image

24, May 2008

MSDN Magazine revisits OBA development

Filed under: Office Business Application,Visual Studio 2008,VSTO — patrickyong @ 1:14 am

It has been sometime since there is an issue of MSDN mag that focuses on Office Business Application development. I believe not since before Visual Studio 2008 released. Visual Studio 2008 does comes with a lot of new tools inside VSTO for OBA development and it is worth while to have a look what you can achieve easily here.

Editor’s note on why one should think of Office as a development platform http://msdn.microsoft.com/en-us/magazine/cc507637.aspx

Document Automation using VBA to VSTO
http://msdn.microsoft.com/en-us/magazine/cc507643.aspx

Automate Web App Deployment with the SharePoint API
http://msdn.microsoft.com/en-us/magazine/cc507633.aspx

Integrate VSTO with SharePoint Content Types
http://msdn.microsoft.com/en-us/magazine/cc507632.aspx

23, May 2008

Compatibility Pack for Office 2007 file format does not render <w:dataBinding>

Filed under: OpenXML,Word — patrickyong @ 10:01 am

I created a Word 2007 file with data binding to a CustomXML part

clip_image001

When I open it in Word 2003 with the capability pack installed, the data is not displayed.

clip_image003

After some investigation, I open up the document.xml (just rename the word file extension to .zip instead of .docx) and realize that the compatibility pack only renders the content inside <w:t> tag and ignores the XPath binding on the <w:dataBinding> tag. Below is a part of my document.xml, notice the blue colored text.

<w:sdt>
– <w:sdtPr>
  <w:dataBinding w:xpath=”/root[1]/name[1]” w:storeItemID=”{b6aa39be-c6d5-40ca-a66e-93dbd069104f}” /> 
  <w:id w:val=”3411243″ />
– <w:placeholder>
  <w:docPart w:val=”DefaultPlaceholder_22675703″ />
  </w:placeholder>
  <w:showingPlcHdr />
  <w:text />
  </w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”006D15FD” w:rsidRDefault=”00F43988″>
– <w:r w:rsidRPr=”00583873″>
– <w:rPr>
  <w:rStyle w:val=”PlaceholderText” />
  </w:rPr>
 
<w:t>Click here to enter text.</w:t>
  </w:r>
  </w:p>
  </w:sdtContent>
  </w:sdt>

If you are creating a WordML document thru this manner and want to enable it for users of older version of Word, remember to update your <w:t> tag as well.

Lim Guan Eng @ WCIT 2008

Filed under: WCIT — patrickyong @ 3:03 am

Yup, I recall he speaks in one of the session. Lim Guan Eng, Chief Minister of Penang paid a visit to the Penang booth on the third day of the event. That makes it a VIP visit during everyday of WCIT.

DSC_1272

22, May 2008

Office 2007 SP2 to have wider document support

Filed under: Office,OpenXML — patrickyong @ 11:58 am

I believe Microsoft is really committed to promote interoperability with other vendors, even when they are direct competitors. Recently announcement on inclusion of ODF and PDF support into Office 2007 Service Pack 2 is a strong evidence.

image

Having said that, the above mentioned 2 document formats have already been supported via freely available addins

  1. PDF Save as in Office 2007
  2. ODF translator for Office 2007

The default and newer MS Office file format still has its own advantage over the others especially for integration works with line of business applications. So after acceptance by ISO, Microsoft will of course continue to work on this format for the benefits of its customers.

Another interoperability evidence would be support of Silverlight inside Linux by Novel, which I think is very cool.

Hi res version of WCIT photos

Filed under: WCIT — patrickyong @ 1:05 am

Uploaded them to my Flickr account. Will be available temporary until Friday which you got to request it from me personally.

http://www.flickr.com/photos/patrickyong/sets/72157605175826878/show/

Have you watched Indiana Jones tonight?

Filed under: Misc — patrickyong @ 12:29 am

This is the night, but due to work tomorrow I was not able to watch it. If you can tell me more about Indiana Jones than Lara Croft, certainly you are around my age. Most of the interns I asked have no single idea about the movie franchise, I wonder what kind of childhood they went through without heroes like Indy.

So in case you are one of the unlucky Y-generation, go to Wikipedia and find out more. My friend who just came back from cinema (she also don’t know anything about Temple of Doom or the lost Ark) told me the starting part is a bit boring with little action but at the end there is a surprise appearance of UFO?! Celaka…. don’t know how true is it for Spielberg and Lucas to go this extreme. Come on lah. I always think Indy’s movie is to encourage kids to study history so leave the flying saucers to George Lucas’ Star Wars lah!

image IndianaTempleDoom
Older and younger Indiana Jones, not much difference, but when you are younger, you dare to show more skin ><

Next Page »

Create a free website or blog at WordPress.com.