Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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");

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.
mayankshrivastava 29-Dec-11 10:47am    
hi i have question a basis on excel file and word file and think so you might be help me out.
i have two ms word document file (2007) save as German.doc and English.doc and one ms office excel file (2007) save as dictionary.xls.

I made two columns in dictionary.xls , German in r1c1 and English in r1c2
Now I write word "LL" in r2c1 and in r2c2 word "MY" in excel file.
now i just wanted to check if German.doc contains word "LL" so it should be write on English.doc as "MY".

but this code is on VB.

Please help me out.

Thanks ......

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900