Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?


Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the excel
desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in the newly
opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

| www.XLsupport.com | keepITcool chello nl | amsterdam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?

Hi KeepITcool,

You know very considerably more about API's than I, but I think I would
disable the application windows, rather than the workbook windows (btw how
?). In other words restore to a normal modal form state.

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal bEnable As Long) As Long

Private Sub UserForm_Click()
Dim v
Dim nHWind As Long

v = Application.GetOpenFilename
If v < False Then Workbooks.Open v

AppActivate Me.Caption
nHWind = FindWindowA("XLMAIN", Application.Caption)
EnableWindow nHWind, 0&

End Sub

Regards,
Peter T

"keepITcool" wrote in message
.com...

Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the excel
desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in the newly
opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

| www.XLsupport.com | keepITcool chello nl | amsterdam



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?

Peter,

thanx. so simple.

enablewindow for the application does the trick.
to refocus the form after the dialog i added the bringtotop.

in some cases it's preferable over hiding/showing the userform.
as the userform_activate event isnt triggered.


Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias
"FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub CommandButton1_Click()
Dim v, h&
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
h = FindWindow(vbNullString, Application.Caption)
EnableWindow h, 0&
h = FindWindow(vbNullString, Me.Caption)
BringWindowToTop h
End Sub

Private Sub UserForm_Activate()
MsgBox "activated!"
End Sub


Private Sub CommandButton2_Click()
Dim v, h&
Me.Hide
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
Me.Show
End Sub






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter T wrote :

Hi KeepITcool,

You know very considerably more about API's than I, but I think I
would disable the application windows, rather than the workbook
windows (btw how ?). In other words restore to a normal modal form
state.

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal bEnable As Long) As Long

Private Sub UserForm_Click()
Dim v
Dim nHWind As Long

v = Application.GetOpenFilename
If v < False Then Workbooks.Open v

AppActivate Me.Caption
nHWind = FindWindowA("XLMAIN", Application.Caption)
EnableWindow nHWind, 0&

End Sub

Regards,
Peter T

"keepITcool" wrote in message
.com...

Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the
excel desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in the
newly opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

www.XLsupport.com | keepITcool chello nl | amsterdam

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?

Glad it worked.

Slightly off topic I notice you changed one, but not both of the API's to
Alias. Could you clarify which is preferable, or are they directly the
interchangeable in all situations.

FindWindowA Lib "user32"
vs
FindWindow Lib "user32.dll" Alias "FindWindowA"

EnableWindow Lib "user32"
vs
EnableWindow Lib "user32" Alias "EnableWindow"

and similar with other API's

TIA,
Peter T

"keepITcool" wrote in message
.com...
Peter,

thanx. so simple.

enablewindow for the application does the trick.
to refocus the form after the dialog i added the bringtotop.

in some cases it's preferable over hiding/showing the userform.
as the userform_activate event isnt triggered.


Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias
"FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub CommandButton1_Click()
Dim v, h&
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
h = FindWindow(vbNullString, Application.Caption)
EnableWindow h, 0&
h = FindWindow(vbNullString, Me.Caption)
BringWindowToTop h
End Sub

Private Sub UserForm_Activate()
MsgBox "activated!"
End Sub


Private Sub CommandButton2_Click()
Dim v, h&
Me.Hide
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
Me.Show
End Sub






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter T wrote :

Hi KeepITcool,

You know very considerably more about API's than I, but I think I
would disable the application windows, rather than the workbook
windows (btw how ?). In other words restore to a normal modal form
state.

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal bEnable As Long) As Long

Private Sub UserForm_Click()
Dim v
Dim nHWind As Long

v = Application.GetOpenFilename
If v < False Then Workbooks.Open v

AppActivate Me.Caption
nHWind = FindWindowA("XLMAIN", Application.Caption)
EnableWindow nHWind, 0&

End Sub

Regards,
Peter T

"keepITcool" wrote in message
.com...

Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the
excel desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in the
newly opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

www.XLsupport.com | keepITcool chello nl | amsterdam



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?


just copied them from "ApiViewer 2004"

not too sure about specifics..

the name BEFORE the alias is used in code
the name AFTER alias is the actual dll.function called.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter T wrote :

Glad it worked.

Slightly off topic I notice you changed one, but not both of the
API's to Alias. Could you clarify which is preferable, or are they
directly the interchangeable in all situations.

FindWindowA Lib "user32"
vs
FindWindow Lib "user32.dll" Alias "FindWindowA"

EnableWindow Lib "user32"
vs
EnableWindow Lib "user32" Alias "EnableWindow"

and similar with other API's

TIA,
Peter T

"keepITcool" wrote in message
.com...
Peter,

thanx. so simple.

enablewindow for the application does the trick.
to refocus the form after the dialog i added the bringtotop.

in some cases it's preferable over hiding/showing the userform.
as the userform_activate event isnt triggered.


Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias
"FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub CommandButton1_Click()
Dim v, h&
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
h = FindWindow(vbNullString, Application.Caption)
EnableWindow h, 0&
h = FindWindow(vbNullString, Me.Caption)
BringWindowToTop h
End Sub

Private Sub UserForm_Activate()
MsgBox "activated!"
End Sub


Private Sub CommandButton2_Click()
Dim v, h&
Me.Hide
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
Me.Show
End Sub






--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



Peter T wrote :

Hi KeepITcool,

You know very considerably more about API's than I, but I think I
would disable the application windows, rather than the workbook
windows (btw how ?). In other words restore to a normal modal form
state.

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal bEnable As Long) As Long

Private Sub UserForm_Click()
Dim v
Dim nHWind As Long

v = Application.GetOpenFilename
If v < False Then Workbooks.Open v

AppActivate Me.Caption
nHWind = FindWindowA("XLMAIN", Application.Caption)
EnableWindow nHWind, 0&

End Sub

Regards,
Peter T

"keepITcool" wrote in message
.com...

Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the
excel desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in
the newly opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

www.XLsupport.com | keepITcool chello nl | amsterdam



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default GetOpenFileName called from modal userform.. enables workbook windows. BUG?


not too sure about specifics..


me much less so :-)

both ways seem to work

Thanks,
Peter T


the name BEFORE the alias is used in code
the name AFTER alias is the actual dll.function called.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter T wrote :

Glad it worked.

Slightly off topic I notice you changed one, but not both of the
API's to Alias. Could you clarify which is preferable, or are they
directly the interchangeable in all situations.

FindWindowA Lib "user32"
vs
FindWindow Lib "user32.dll" Alias "FindWindowA"

EnableWindow Lib "user32"
vs
EnableWindow Lib "user32" Alias "EnableWindow"

and similar with other API's

TIA,
Peter T

"keepITcool" wrote in message
.com...
Peter,

thanx. so simple.

enablewindow for the application does the trick.
to refocus the form after the dialog i added the bringtotop.

in some cases it's preferable over hiding/showing the userform.
as the userform_activate event isnt triggered.


Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias
"FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub CommandButton1_Click()
Dim v, h&
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
h = FindWindow(vbNullString, Application.Caption)
EnableWindow h, 0&
h = FindWindow(vbNullString, Me.Caption)
BringWindowToTop h
End Sub

Private Sub UserForm_Activate()
MsgBox "activated!"
End Sub


Private Sub CommandButton2_Click()
Dim v, h&
Me.Hide
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
Me.Show
End Sub






--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam


Peter T wrote :

Hi KeepITcool,

You know very considerably more about API's than I, but I think I
would disable the application windows, rather than the workbook
windows (btw how ?). In other words restore to a normal modal form
state.

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal bEnable As Long) As Long

Private Sub UserForm_Click()
Dim v
Dim nHWind As Long

v = Application.GetOpenFilename
If v < False Then Workbooks.Open v

AppActivate Me.Caption
nHWind = FindWindowA("XLMAIN", Application.Caption)
EnableWindow nHWind, 0&

End Sub

Regards,
Peter T

"keepITcool" wrote in message
.com...

Anyone knows a fix for this?
or should I use API's to disable the workbook windows?

New workbook, insert a userform with following code

Private Sub UserForm_Click()
Dim v
v = Application.GetOpenFilename
If v < False Then Workbooks.Open v
End Sub

run the form. (MODAL)
click the form and open a workbook.

Excel menu;s are still disabled, but all workbook windows in the
excel desktop are now ENABLED!

Context menu's ARE available. try copy and paste somewhere in
the newly opened workbook. and excel will crash. (XP/ 2003)

(minimizing a workbook is ok. but if you close the
newly opened workbook via the "X button it crashed your form.
with an "automation error: invoked a disconnect" error.


--
keepITcool

www.XLsupport.com | keepITcool chello nl | amsterdam



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
Userform modal Dave K[_3_] Excel Discussion (Misc queries) 1 April 9th 10 07:41 AM
Forms that are modal in 97 are not modal in 2003 Old Car Excel Discussion (Misc queries) 1 April 27th 05 08:25 AM
Forms that are modal in 97 are not modal in 2003 Old Car Excel Programming 1 April 27th 05 08:25 AM
Button on Userform calling GetOpenFilename Werner Rohrmoser Excel Programming 2 March 22nd 05 07:15 AM
Excel97 Userform to be system modal/equivalent George J Excel Programming 2 September 26th 04 11:05 PM


All times are GMT +1. The time now is 07:53 PM.

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

About Us

"It's about Microsoft Excel"