ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate Non-Excel Window Through VBA (https://www.excelbanter.com/excel-programming/275998-activate-non-excel-window-through-vba.html)

Mark Bigelow

Activate Non-Excel Window Through VBA
 
Hello!

I'd like to activate an Excel window (SAP) through VBA and then use
SendKeys to input the selection criteria for a certain report, and then
run the report. I think this will be easier than explaining how to run
the report.

So, how can I activate the window?

Thanks!
Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Chip Pearson

Activate Non-Excel Window Through VBA
 
Mark,

Try something like the following

Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SetForegroundWindow Lib "user32" ( _
ByVal HWnd As Long) As Long


Sub AAA()
Dim HWnd As Long
HWnd = FindWindow(vbNullString, "SAP")
If HWnd Then
SetForegroundWindow HWnd
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Mark Bigelow" wrote in message
...
Hello!

I'd like to activate an Excel window (SAP) through VBA and then use
SendKeys to input the selection criteria for a certain report, and then
run the report. I think this will be easier than explaining how to run
the report.

So, how can I activate the window?

Thanks!
Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com