Userform appears behind other application
All displayed windows are in front of the desktop, I expect you mean you
want your form to appear in front of Powerpoint. Depending on what you want
to do maybe simply appActivate is enough after displaying PP, eg
AppActivate Me.Caption
If you want to attach your form to your Powerpoint have a go with this -
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Const GWL_HWNDPARENT = (-8)
Dim mPPhWnd As Long
Dim mFrmHwnd As Long
Private Sub CommandButton1_Click()
Dim oPP As Object
Set oPP = CreateObject("powerpoint.application")
oPP.Visible = True
mPPhWnd = FindWindow(vbNullString, oPP.Caption)
mFrmHwnd = FindWindow("ThunderDFrame", Me.Caption)
SetWindowLongA mFrmHwnd, GWL_HWNDPARENT, mPPhWnd
AppActivate Me.Caption
End Sub
Regards,
Peter T
"simonc" wrote in message
...
I am writing a macro which opens a powerpoint file and extracts
information
from it into a spreadsheet. I have a user form which asks for information
about the spreadsheet to use for output but this appears behind the
powerpoint window. Is there a way of forcing a userform to come to the
front
of the desktop?
Grateful for ideas.
|