GetOpenFilename changes dialog to modless

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
 
N

NickHK

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
 
A

Alex Trueman

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
 
A

Alex Trueman

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
 
N

NickHK

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
 
T

Tom Ogilvy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top