0 Comments

While playing around with SharePoint 2010, I want to add a link to my site home page that will do the same thing when I am in a particular document / form library and click the Add Document link. 

In other word, how can I launch Word or Excel or InfoPath from my own link without having to go inside the library and clicking Add Document?

At first, I couldn't figure out how to do this.  Decided to dive into the HTML source of the Form Library AllItems.aspx view and found a CoreInvoke JS method, like:

CoreInvoke(
    'createNewDocumentWithProgIDEx', 
    'template source URI', 
    event, 
    'save location URI', 
    'SharePoint.OpenXMLDocuments', 
    true); 

I plop that inside a link tag and it worked. 

After the fact, I look around the web and finally found someone else that has done this already...

See: http://www.sharepointkings.com/2010/02/create-new-document-link-in-listview.html

The syntax is something like:

createNewDocumentWithProgID(templateSourceURI, saveLocation, docType, false);

In my case, I want to launch an InfoPath form template, and I found the following work just fine:

createNewDocumentWithProgID(
    'http://intranet/spike/FormLib1/Forms/template.xml', 
    'http://intranet/spike/FormLib1', 
    'SharePoint.OpenXMLDocuments', 
    false);