Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tried your suggestion but haven't made it work yet.
The main programme opens the userform with frmOutputFile.Show In the form code I tried putting Appactivate me.caption in a Private Sub UserForm_Initialize() subroutine, but it didn't bring the form to the front. The Excel window title bar still flashes while waiting for input from the form. Do I need to put AppActivate in a different place? thanks. "Peter T" wrote: 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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How and when do you reference PowerPoint, and when do you show you form.
Regards, Peter T "simonc" wrote in message ... I tried your suggestion but haven't made it work yet. The main programme opens the userform with frmOutputFile.Show In the form code I tried putting Appactivate me.caption in a Private Sub UserForm_Initialize() subroutine, but it didn't bring the form to the front. The Excel window title bar still flashes while waiting for input from the form. Do I need to put AppActivate in a different place? thanks. "Peter T" wrote: 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. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter
Thanks for that, I think you've answered my question before I asked it. I've not completely tried it out but it appears that if the form is set to non modal (ShowModal=False) it does appear in front of the PowerPoint window. regards Martin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
%1 appears in "Application used to perform action" when trying to edit a file type | Excel Worksheet Functions | |||
Listing Application Userform Contents | Excel Programming | |||
application userform database problem | Excel Programming | |||
How to keep userform always on the top of all windows application | Excel Discussion (Misc queries) | |||
Failed userform loading and cause application crash | Excel Programming |