C# Interaction.AppActivate Procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
I see using this approach fails when Excel is minimized.

Nicholas Paldino said:
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]
- (e-mail address removed)

mr peanut said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

c# version of InStr? 1
c# equiv of GetObject and casting 3
thread synchronization??? 4
Native C#? 8
Create Method 1
Activating Word from Access 2007 problem 1
large (>2G) addresses 4
Can C# be as fast as C++? 9

Back
Top