Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you correctly guessed in the comment above that taking the focus away from notepad will solve your problem. The below code does exactly that.</p> <p><strong>LOGIC</strong>:</p> <p><strong>A</strong>. Loop through the shape and get it's name. In your scenario it would be something like <code>Chart Meta XML_fbc9775a-19ea-.txt</code></p> <p><img src="https://i.stack.imgur.com/M8pDP.png" alt="enter image description here"></p> <p><strong>B</strong>. Use APIs like <code>FindWindow</code>, <code>GetWindowTextLength</code>, <code>GetWindow</code> etc to get the handle of the notepad window using <strong>partial caption</strong>.</p> <p><strong>C</strong>. Use the <code>ShowWindow</code> API to minimize the window</p> <p><strong>Code (tested in VBA-Powerpoint)</strong></p> <p>Paste this code in a module in the above PPTM</p> <pre><code>Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" _ (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindowTextLength Lib "User32" Alias _ "GetWindowTextLengthA" (ByVal hWnd As Long) As Long Private Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, _ ByVal wCmd As Long) As Long Private Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const GW_HWNDNEXT = 2 Private Const SW_SHOWMINIMIZED = 2 Sub Sample() Dim shp As Shape Dim winName As String Dim Ret As Long For Each shp In ActivePresentation.Slides(1).Shapes If shp.Type = msoEmbeddedOLEObject Then winName = shp.Name shp.OLEFormat.Activate Exit For End If Next If winName &lt;&gt; "" Then Wait 1 If GetHwndFromCaption(Ret, Replace(winName, ".txt", "")) = True Then Call ShowWindow(Ret, SW_SHOWMINIMIZED) Else MsgBox "Window not found!", vbOKOnly + vbExclamation End If End If End Sub Private Function GetHwndFromCaption(ByRef lWnd As Long, ByVal sCaption As String) As Boolean Dim Ret As Long Dim sStr As String GetHwndFromCaption = False Ret = FindWindow(vbNullString, vbNullString) Do While Ret &lt;&gt; 0 sStr = String(GetWindowTextLength(Ret) + 1, Chr$(0)) GetWindowText Ret, sStr, Len(sStr) sStr = Left$(sStr, Len(sStr) - 1) If InStr(1, sStr, sCaption) &gt; 0 Then GetHwndFromCaption = True lWnd = Ret Exit Do End If Ret = GetWindow(Ret, GW_HWNDNEXT) Loop End Function Private Sub Wait(ByVal nSec As Long) nSec = nSec + Timer While nSec &gt; Timer DoEvents Wend End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload