Opening Sharepoint documents for Edit from NAV2013

KjeldLoberKjeldLober Member Posts: 2
edited 2013-12-19 in NAV Three Tier
Hi,
Is there anybody who had tried to open a Sharepoint Document from NAV 2013 using .net components. ?
The ActiveX component “SharePoint.OpenDocuments” is used to open SharePoint documents ready for editing.
If you hyperlink then DocumentURL it will open, but it will always be opened read-only.

I have tried to "recode":

The following code will create an version specific instance of SharePoint.OpenDocuments and then call the EditDocument method to open the document:

.net:

public static void OpenDocumentForEdit(string docUrl)

{
Type t = null;
// get the correct version specific version...
t = Type.GetTypeFromProgID("SharePoint.OpenDocuments.1");
if (t == null)
t = Type.GetTypeFromProgID("SharePoint.OpenDocuments.2");
if (t == null)
t = Type.GetTypeFromProgID("SharePoint.OpenDocuments.3");
if (t == null)

{
System.Diagnostics.Process.Start(docUrl);
// best we can do, will open read-only
return;
}

Object o = Activator.CreateInstance(t);
object[] openParms = { docUrl, string.Empty };
t.InvokeMember("EditDocument",System.Reflection.BindingFlags.InvokeMethod |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance,null, o, openParms);

}

NAV2013:
Var:
type DotNet System.Type.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
obj DotNet System.Object.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
openParm DotNet System.Object.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
nullBinder DotNet System.Reflection.Binder.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
systemActivator DotNet System.Activator.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
parmstr Text 1024
Param Text 1024

EditDocument(URL)
openParm := openParm.Object;
openParm.ReferenceEquals(URL,'');

bindingFlags1 := 276;

parmstr := '';
type := type.GetTypeFromProgID('SharePoint.OpenDocuments.1');
IF ISNULL(type) THEN
type := type.GetTypeFromProgID('SharePoint.OpenDocuments.2');
IF ISNULL(type) THEN
type := type.GetTypeFromProgID('SharePoint.OpenDocuments.3');
IF ISNULL(type) THEN
HYPERLINK(URL);

obj := systemActivator.CreateInstance(type);

type.InvokeMember('EditDocument', bindingFlags1, nullBinder ,obj, openParm);

Any ideas?
Sign In or Register to comment.