470,594 Members | 1,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

Taking control of an existing instance of Excel

User has opened an excel file and I want to take the control of the file. In
VB6 was not hard. Just I needed to use "GetObject" then I could select the
workbook. But now I don't know how to do it in C#.

Thanks
Nov 17 '05 #1
2 1771
Adine,

You will want to use the static GetActiveObject method on the Marshal
class to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adine" <ad********@yahoo.com> wrote in message
news:s5******************************@magma.ca...
User has opened an excel file and I want to take the control of the file.
In VB6 was not hard. Just I needed to use "GetObject" then I could select
the workbook. But now I don't know how to do it in C#.

Thanks

Nov 17 '05 #2
I used:

excelObj =
(Excel.Application)System.Runtime.InteropServices. Marshal.GetActiveObject("Excel.Application");

but did not work. I have opened 2 excel files but excelObj.Workbooks.Count
shows zero!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O8**************@TK2MSFTNGP14.phx.gbl...
Adine,

You will want to use the static GetActiveObject method on the Marshal
class to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adine" <ad********@yahoo.com> wrote in message
news:s5******************************@magma.ca...
User has opened an excel file and I want to take the control of the file.
In VB6 was not hard. Just I needed to use "GetObject" then I could select
the workbook. But now I don't know how to do it in C#.

Thanks


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Fred Morrison | last post: by
3 posts views Thread by Ian Dunn | last post: by
1 post views Thread by shapper | last post: by
5 posts views Thread by John Kotuby | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.