GetOpenFilename changes dialog to modless

  • Thread starter Thread starter Alex Trueman
  • Start date Start date
A

Alex Trueman

Hi,

I have a modal dialog with a browse button. Clicking the button uses the
GetOpenFilename method to populate a text box. For some reason, after
running GetOpenFilename the dialog changes to modeless. Can anyone tell
me why this happens and how to prevent it or cure it?

Thanks,
Alex
 
Alex,
Using something like:
UserForm1.Show vbModal
and
TextBox1.Text=Application.GetOpenFileName()

has no effect on the modality of the userform for me.

Are you doing the same ?

NickHK
 
NickHK,

I'm using the same syntax as you (see below) except that I'm changing
the value property not the text property. I thought that maybe the
modality was being changed so that the 'open' dialog could be displayed.

frmImportVarMods.Show vbModal

and

tbxImportFile.Value = Application.GetOpenFilename( _
filefilter:="text(*.txt),*.txt,all (*.*),*.*", _
Title:="Import File", MultiSelect:=False)

Alex
 
Further to last message:

The modality is affected but not completely changed. I can access cells
and the formula editor but not the menus.

Alex
 
Alex,
You are able to place the cursor there, but no text can be entered.
I guess that is what Excel takes to be Modal.

NickHK
 
In Excel 97, there was no option to show Userforms as modeless. However,
Stephen Bullen discovered the "bug" you highlight - that showing the
getopenfilename dialog made the userform modeless. He and Rob Bovey later
discovered that showing getopenfilename actually called an API function
which was the actual cause of this effect. I don't remember the details,
but you can check out the procedure at Stephen's site (where he has
converted it to use the API call rather than showing the getopenfilename).

http://www.BSMLTD.ie

go to the excel page from there.
 
Back
Top