468,309 Members | 1,066 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

C# Interaction.AppActivate Procedure

I want to activate an application (Excel) in code. If I reference
microsoft.visualbasic, I could use:

Interaction.AppActivate("Microsoft Excel");

But I wold rather use a native C# approach. I know that Interaction.MsgBox
has a native analog: MessageBox.Show.

Is there one for AppActivate?
Aug 21 '07 #1
2 8550
There is no managed equivalent other than the VB implementation. It
ends up calling SetForegroundWindow, but it does a great deal of other setup
as well (getting the window handle, checking to see if it is enabled, etc,
etc), so you might want to use the class in VB.

Note, the Interaction class in the Microsoft.VisualBasic namespace IS
managed code, and is no less native to .NET than any classes you might use
in the System namespace, or anything else. C# is the language, the glue
that you use for calling existing managed code constructs.

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

"mr peanut" <mr******@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
>I want to activate an application (Excel) in code. If I reference
microsoft.visualbasic, I could use:

Interaction.AppActivate("Microsoft Excel");

But I wold rather use a native C# approach. I know that
Interaction.MsgBox
has a native analog: MessageBox.Show.

Is there one for AppActivate?

Aug 22 '07 #2
I see using this approach fails when Excel is minimized.

"Nicholas Paldino [.NET/C# MVP]" wrote:
There is no managed equivalent other than the VB implementation. It
ends up calling SetForegroundWindow, but it does a great deal of other setup
as well (getting the window handle, checking to see if it is enabled, etc,
etc), so you might want to use the class in VB.

Note, the Interaction class in the Microsoft.VisualBasic namespace IS
managed code, and is no less native to .NET than any classes you might use
in the System namespace, or anything else. C# is the language, the glue
that you use for calling existing managed code constructs.

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

"mr peanut" <mr******@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
I want to activate an application (Excel) in code. If I reference
microsoft.visualbasic, I could use:

Interaction.AppActivate("Microsoft Excel");

But I wold rather use a native C# approach. I know that
Interaction.MsgBox
has a native analog: MessageBox.Show.

Is there one for AppActivate?


Aug 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by DottingTheNet | last post: by
1 post views Thread by Alex | last post: by
reply views Thread by Austin | last post: by
reply views Thread by Omar Abid | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.