Skip to main content

SharePoint: How to create a custom action to open Word Documents using "Edit in Microsoft Word".

Imagine you have a SharePoint custom search webpart, and on your search results, you return word documents, you will obviously want to at times be able to open them in your MS Word client program for editing.

So basically, depending on your office client installed on your local machine, there are 2 different approaches that can be made for Office 2003 and Office 2007/10, using the same function "
editDocumentWithProgID2".

For Office 2003:

- If your document libraries versioning settings have got "Require Check out" ticked, then you will first want to check out the document using:

onclick="CheckoutviaXmlhttp(‘{SiteURL}’, ‘{DocumentDownloadURL}’)"

- Then to open the document, you use:

onclick="return editDocumentWithProgID2(‘{DocumentDownloadURL}’, ”, ‘SharePoint.OpenDocuments’, ’1′,’{SiteURL}’, ’0′);" href="#"

- and now combining the above 2 actions into one clickable action:

onclick="CheckoutviaXmlhttp(‘{SiteURL}’, ‘{DocumentDownloadURL}’); return editDocumentWithProgID2(‘{DocumentDownloadURL}’, ”, ‘SharePoint.OpenDocuments’, ’1′,’{SiteURL}’, ’0′);" href="#"


For Office 2007/10:

- Again if your document libraries versioning settings have got "Require Check out" ticked, this line will do it all, i.e. check out and open the document:

onclick="editDocumentWithProgID2('{DocumentDownloadUrl}', '', 'SharePoint.OpenDocuments', '1', '{SiteUrl}', '0')" href="#"

- Note that the variable "1" means that the document is being opened in Edit mode. If you change it to 0, the document would open in read-only mode.


Happy Coding!

Comments

Anonymous said…
Do I need to add any dll or java script from SharePoint to my project to use this?
I will check back for any response. Thank you, this would be great if I could use it.

My application is not on the same server as SharePoint at my site.
Anonymous said…
dude, seriously change your font colors, cannot read anything here.

Popular posts from this blog

Zambia's first Helpdesk System on SharePoint

For my 25th birthday today 3rd March, 2009, allow me to present to you another first of its kind in Zambia. Yes we have done it again, having been Project manager, I present to you Zambia's first Helpdesk System which Masialeti and I have developed on Microsoft Office SharePoint Server 2007. The system also implements SharePoint designer workflows, Infopath forms, SharePoint document library and sends email notifications to the relevant personnel. When a user logs in a call, the user automatically receives a mail from the system, telling them that their call has been received and is being attended to, IT section will also receive a notification and the helpdesk manager will assign the call to the right IT guy who will also automatically receive a mail notification from the system. When the call is resolved, the user again automatically gets notified by the system with a mail giving them description of the problem they logged and also how it has been resolved. The user also has an

How to implement a SharePoint "Change Management Process"

Not so much from the technical point of view, SharePoint Change Management is the process of monitoring and controlling changes within a SharePoint project. By managing the implementation of change, you can: • Reduce the impact of changes to the SharePoint project • Identify new issues and risks as a result of changes raised • Ensure that changes do not affect the SharePoint project's ability to achieve its desired objectives • Control the cost of change within the SharePoint project Change Management is comprised of the following processes: Step 1: Identify Change: The first step in the change process is to identify the need for change. Any team member can suggest a change to the SharePoint project, if he or she believes it is needed to keep the SharePoint project producing deliverables to the customer's specified requirements. After identifying a need for change, the team member records relevant information on a Change Request Form (commonly called a CRF), describing the chan