Hello there is a possibility to use a library. Net with Delphi XE2? This is the library DocX.dll available here http://docx.codeplex.com/. Thanks in advance.
Asked
Active
Viewed 534 times
0
-
http://stackoverflow.com/q/7994852/62576 – Ken White Sep 25 '13 at 15:29
-
1The simple answer is "yes" – David Heffernan Sep 25 '13 at 15:30
-
1You can use mscorlib_TLB,mscoree_TLB unit from JCL . – S.MAHDI Sep 25 '13 at 17:55
-
What I want to do is something like this http://msdn.microsoft.com/en-us/library/cc974107(v=office.12).aspx but in delphi. – Domenico Formoso Sep 26 '13 at 08:05
1 Answers
0
using (DocX document = DocX.Load("Test.docx"))
{
document.ReplaceText("pear", "banana", true, RegexOptions.IgnoreCase);
document.Save();
}
Delphi:
var
Host: TJclClrHost;
Obj: OleVariant;
Assm: _Assembly;
T: _Type;
Params1: Variant;
params2:Variant;
begin
Host := TJclClrHost.Create('v4.0.30319');
Host.Start;
Assm := Host.DefaultAppDomain.Load_2('DocX');
T := Assm.GetType_2('Novacode.DocX');
// Obj:=T.InvokeMember_3('', BindingFlags_CreateInstance, nil, null, nil);
Params1 := VarArrayOf(['sample.docx']);
obj:=T.InvokeMember_3('Load', BindingFlags_InvokeMethod, nil, null, PSafeArray(VarArrayAsPSafeArray(Params1)));
Params2 := VarArrayOf(['Before','After']);
t.InvokeMember_3('ReplaceText', BindingFlags_InvokeMethod, nil, Obj, PSafeArray(VarArrayAsPSafeArray(Params2)));
t.InvokeMember_3('Save', BindingFlags_InvokeMethod, nil, Obj, nil);
Host.Stop;
end;
t.InvokeMember_3('ReplaceText',..... generates error:the method "Novacode.DocX.ReplaceText" does not exist. I can not call the method ReplaceText (because it is an inherited method?)

Domenico Formoso
- 137
- 7