I am creating an application which uses global hotkeys to copy selected text from currently focused application. My application runs in background & monitors clipboard using WinProc method.
The problem is copying text from Excel spreadsheet, when multiple Worhbooks of excel application are running, it always copy selected text of first workbook opened.
I have searched a lot regarding how to access different workbooks, or access currently focused workbook, but none of the method worked for me.
I want to use this case scenario:
1) User opens a new Excel Workbook (say WorkBook1).
2) User press hotkey (say CTRL+ALT+V), (Working fine)
3) User opens another new Excel workbook (say WorkBook2).
4) User press hotkey, focusing new workbook. (not working, it is copying selected text from first instance of workbook).
I used the following code to get Excel Application:
Excel.Application objExcel;
objExcel = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
...
using
objExcel.ActiveWorkbook.Name
always gives me the name of first workbook opened.
I only need to access selected text from current active workbook using C# code.
Can anyone please help me solving this problem...
Thanks in advance.