We help IT Professionals succeed at work.

Can't get the filedialog buttonname property to work

hallpett
hallpett asked
on
I use the filedialog to select a file and return a filename. See code below.
I expected my use of the the ButtonName property to change the caption on the action button from the default "Open" to "Select", but that don't happen. The code runs without any errors. Is there something I have misunderstood? Appreciate any tips.

Dim fd    As Object
Set fd = Application.FileDialog(3) '3 = filepicker

    With fd
        .Title = "Velg en fil"
        .ButtonName = "Select"
        .AllowMultiSelect = False
        ' Clear out the current filters, and add our own.
        .Filters.Clear
        .Filters.Add "Word dokument", "*.doc"
        .Filters.Add "PDF filer", "*.pdf"
        .Filters.Add "Alle Filer", "*.*"
        .InitialFileName = "D:\Temp\"
        If .Show = True Then
            MsgBox "file choosen = " & f.SelectedItems(1)
        Else
            MsgBox "You clicked Cancel in the file dialog box."
        End If
    End With
 Set fd = Nothing
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Fwiw, your code is woking as expected here.

The button caption is "Select"
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Have you posted your code in it's entirety?
CERTIFIED EXPERT
Top Expert 2016

Commented:
if you have placed  "Option Explicit" atthe top of your module

this line will give you error

MsgBox "file choosen = " & f.SelectedItems(1)

it should be

MsgBox "file choosen = " & fd.SelectedItems(1)

Author

Commented:
The missing "d" in f.SelectedItems(1) is a copy/paste mistake, sorry about that. But it don't affect my problem with the Buttonname property. Except the error above I have posted my code entirely. Can the buttonname property behave different with my norwegian access 2010 version? Since I don't use any reference to MS Office 14 object library i guess that can't be the problem.
CERTIFIED EXPERT
Top Expert 2016

Commented:
you are using late binding, so you don't need the reference to the Office library.

<Can the buttonname property behave different with my norwegian access 2010 version? >
it should not..
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
The system I'm testing it on is Access 2007.  It may be different in Access 2010, but I'd be surprised if the language made a difference.
CERTIFIED EXPERT
Top Expert 2016

Commented:
so you created the app in A2010 and doing a test in A2007 version?

see this link as reference

http://msdn.microsoft.com/en-us/office/cc907897


* if you will be using the app in different versions, it is best that you develop the app using the lower/lowest version of access
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Rey,

That was my remark about testing under Access 2007 (I don't think the author has mentioned anything other than Access 2010 yet).  Were you getting our comments confused?
CERTIFIED EXPERT
Top Expert 2016

Commented:
ooohhh... sorry.. need more coffee.
btw, i'll still be your wingman if you decided to do it again ;-)
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Lol!  Lets see how things go this week.  That's a lot of work (and time).  I might have to be your wing person this month :)

Author

Commented:
I created the app in A2010 and I can't get the buttonname property to work in A2010. When I now do a test in A2007 I get a different looking file dialog but the action button gets the wanted "Select" caption. Could it be that the filedialog object is not completly compatibel with A2010?  
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
<<Could it be that the filedialog object is not completly compatibel with A2010?  >>

I believe you hit the nail on the head.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Interesting, though.  It is listed as a property in MS's Access 2010 documentation:
http://msdn.microsoft.com/en-us/library/microsoft.office.core.filedialog.buttonname.aspx

(That does not necessarily mean anything, though)
CERTIFIED EXPERT
Top Expert 2016

Commented:
i'll do a test this afternoon... no A2010 at the moment
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
I'm seeing the same thing.

The code works fine under WinXP/Access 2007

but the ButtonName property does not work under Win 7/ Access 2010

Commented:
Have built same on A2010 and A2007 and both behave the same on this machine.
Win 7 x 64.
I do not see Select in any combination.

Files attached.

Hope this contributes.
Cheers
JC


filedialogueA07-210bld.zip

Author

Commented:
This is strange! I have now tested a bit more. What I discover is that the actionbutton only get the "Select" caption as long that there is no files or folders to select in the right part of filedialog window. As soon as the right pane shows files or folders the caption goes back to "Open". It's not the biggest deal concerning my solution, but at this moment I'm mostly curious about why it behave like it does.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
It sounds like a bug more than a feature.
CERTIFIED EXPERT
Top Expert 2016
Commented:
this seems to be a bug..

miriam,
can you do the honor of presenting this to the mvp group?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013
Commented:
Rey,

Just sent you an email...