ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Displaying the active power point file (https://www.excelbanter.com/excel-programming/386096-re-displaying-active-power-point-file.html)

Francisco Parrilla

Displaying the active power point file
 
Copy / Paste this in a module an associate with a button in a spreadsheet:

'Para fijar la ventana
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"

Asign this macro a button in your spreadsheet:

Sub SetVentana()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
' MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
' PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub

Important:

You must type in Inputbox exactly like your window application powerpoint appear in your title.

Regards

Francisco Parruilla
Sistem Operator
Monterrey NL Mexico





"Francisco Parrilla" escribió en el mensaje news:...
Hi;

Maybe you must use to API´s for locate there windows where yo have your PPT window and send a signal for maximamize window.

Regards

Francisco Parrilla

"NickHK" escribió en el mensaje ...
AppActivate ?

NickHK

"avi" wrote in message
oups.com...
Hello,

A simple and hopefully easy question. I want to place a button on an
Excel UserForm that causes the active PPT file to become the active
window

The PPt file is already open

What code should be in the button?

Thanks
Avi





Madhan

Displaying the active power point file
 
Hi, in my opinion, create a Powerpoint object and open the relevant PPT.
Finally call the close method on the Powerpoint object. No need to use window
handles etc...

"Francisco Parrilla" wrote:

Copy / Paste this in a module an associate with a button in a spreadsheet:

'Para fijar la ventana
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"

Asign this macro a button in your spreadsheet:

Sub SetVentana()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
' MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
' PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub

Important:

You must type in Inputbox exactly like your window application powerpoint appear in your title.

Regards

Francisco Parruilla
Sistem Operator
Monterrey NL Mexico





"Francisco Parrilla" escribió en el mensaje news:...
Hi;

Maybe you must use to API´s for locate there windows where yo have your PPT window and send a signal for maximamize window.

Regards

Francisco Parrilla

"NickHK" escribió en el mensaje ...
AppActivate ?

NickHK

"avi" wrote in message
oups.com...
Hello,

A simple and hopefully easy question. I want to place a button on an
Excel UserForm that causes the active PPT file to become the active
window

The PPt file is already open

What code should be in the button?

Thanks
Avi






All times are GMT +1. The time now is 12:25 AM.

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