Late binding in C# to Word Control in XAML/Store app
Previously I've been able to find a Word document inside another application using
[DllImport("Oleacc.dll")]
private static extern long AccessibleObjectFromWindow(int windowHandle, int objectID, Guid refID, ref IntPtr accessibleObject);
and casting the resultant object returned into a
Microsoft.Office.Interop.Word.Window
This works pretty well in that I can inspect different properties about Word within, say, Microsoft Outlook, as MS Outlook uses a Word Window to render its email content.
However, its a little trickier in XAML/Windows Store app, as it appears that the Word doc is embedded without a direct window handle. Below is the inspector.exe output of the Window. The selected 'Message' item is my Word instance. However the only items in the tree with NativeWindowHandles according to the accessibility inspector are the Mail window and the title window.
Does anyone know how to marshall that Word control in an external XAML/store app into a C# object?
You're out of luck here. What you see here in the Inpect tool is indeed an element which has a "_WwG" class name, but you are not dealing with an automatable instance of Word here.
What is missing here is first of all a native window handle of class "_WwG", and moreover, the code that is used - although being a Microsoft Office 2016 component - does not expose any COM interface that you can access (at least not the familiar COM object model of Word).
Depending on your requirements, you may be able to find a solution based on UI automation - the same kind of inspection technique that is used by the Inspect tool.
链接地址: http://www.djcxy.com/p/55930.html上一篇: 嵌入式文档中的标题栏无法响应