Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Userform appears behind other application

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Userform appears behind other application

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Userform appears behind other application

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userform appears behind other application

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
%1 appears in "Application used to perform action" when trying to edit a file type [email protected] Excel Worksheet Functions 3 December 7th 06 07:00 PM
Listing Application Userform Contents Nigel RS[_2_] Excel Programming 2 October 12th 06 07:32 AM
application userform database problem Pierre via OfficeKB.com[_2_] Excel Programming 0 October 21st 05 03:00 PM
How to keep userform always on the top of all windows application JAtz_DA_WAY Excel Discussion (Misc queries) 1 August 31st 05 01:29 AM
Failed userform loading and cause application crash noiseash Excel Programming 1 August 25th 05 03:35 PM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"