tags:

views:

315

answers:

3

Hi!

In a custom application page I modify a file (word doc), then i call SPFile.CheckOut();

Then I would like to open that file directly in edit modus in word . (As it would have been if the user clicked the file and selected "Edit in Microsoft Office Word" )

Any ideas on how to do that?

EDIT: Yes, I know I can't to this on the server. I'm looking for a way to return some javascript that will open the doc on the client. (I guess there is some javascript built in the checks for the precense of a Office AcitiveX, and then calls it)

Larsi

A: 

This isn't really possibly, mainly because the codebehind runs on the server while you want the client's machine to open word. The best you could do is sent up a meta refresh with the URL of the word document - when hit the user's browser would open the file.

http://sharepoint/sp.doc">

A quick warning: make sure that you check the file out as the current user otherwise your non-admin users will not have rights to open the file.

UJ
Hi! Thanks for answering. I've updated the question for better understanding. BTW, I thought that running the site with Integrated security SPFile.Checkout() would execute with current users privileges?
Larsi
A: 

As UJ says you cannot open it in word on the server.

But you can edit the document on the server using open xml. see : http://www.microsoft.com/downloads/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

Shiraz Bhaiji
A: 

I just did some investigation with Firebug and found this attached to the "Edit in Microsoft Word" link.

<span type="option" text="Edit in Microsoft Office Word" onmenuclick="editDocumentWithProgID2('/sites/I2Validation/KitTestSite/Kits%20Test%20Site%20Documents/Here%20is%20Kit.doc', '', 'SharePoint.OpenDocuments', '0', 'http://servername/sites/I2Validation/KitTestSite', '0')" iconsrc="/_layouts/images/icdoc.gif" iconalttext="" sequence="240" id="ID_EditIn_Microsoft Office Word"/>

I'm thinking you could probably programmatically call editDocumentWithProgID2() after the page has loaded.

Found this in core.js:

function editDocumentWithProgID2(strDocument, varProgID, varEditor, bCheckout,strhttpRoot, strCheckouttolocal)
{
    var errorCode=editDocumentWithProgIDNoUI(strDocument, varProgID, varEditor, bCheckout,strhttpRoot, strCheckouttolocal);
    if (errorCode==1)
    {
     alert(L_EditDocumentRuntimeError_Text);
     window.onfocus=RefreshOnNextFocus;
    }
    else if (errorCode==2)
     alert(L_EditDocumentProgIDError_Text);
}
Kit Menke
Thanks, I think this is just what I need.
Larsi