none
Windows 7 and the VBA openfiledialog object.

    General discussion

  • My Access 2007 application was working fine under Windows XP. I have a function that uses the VBA openfiledialog object to open a file dialog and display only files whose filename matched a criteria gotten from the currently open form. When we upgraded to Windows 7, the file dialog opens but it displays all files instead of those matching the criteria. I am running the application over an eight user LAN. Those PC's on the LAN still using XP are working fine with the open file function, only the PC'S using Windows 7 are malfunctioning.
    Has anyone else experienced this problem and has anyone got a solutiuon?
    Thanks.
    Wednesday, October 07, 2009 9:16 PM

All replies

  • Are you using the Windows 7 RTM, or an earlier beta?
    Wednesday, October 07, 2009 11:29 PM
  • Hello Peter

    On Win7 RTM with Office 2007 Access, I tested the code http://www.mvps.org/access/api/api0001.htm to show a file open dialog with filters:
    Access Files (*.mda, *.mdb)
    dBASE Files (*.dbf)

    The function works well on my side.

    I also tried the Office's built-in FileDialog object, which works well too.

    Dim fld As FileDialog
    Set fld = Application.FileDialog(msoFileDialogOpen)
    fld.Filters.Clear
    fld.Filters.Add "MyText Files", "*.txt"
    fld.Show

    Could you please try those codes in your Win7 system? What's your Win7 version, and could you please share your code snippet here?

    Thanks
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, October 08, 2009 7:40 AM
  • Hi CaptainComet,
    I have just discovered that the version of Windows 7 we are using is 7100 RC. Apparently the RC stands for Release Candidate. Do you think this is the problem. We will get the most current version ASAP.
    Thanks
    Peter

    Monday, October 12, 2009 3:49 AM
  • Hi Jialiang Ge,
    I have just discovered our version of windows 7 is called RC 7100 and is probably a beta version. We will upgrade and I'll' let you know if the problem still exiists.
    Monday, October 12, 2009 3:51 AM
  • If you want to post a code segment that demonstrates the issue it would help, since there are multiple ways to use open dialogs, eg. common dialog or MS Office dialog.

    There were some serious issues with the common dialogs under the first beta, but I thought they were all fixed. I don't remember if any fell through to the RC or not. You can go to this forum:

    http://social.technet.microsoft.com/Forums/en/category/w7itpro/

    and search for common dialog to see what some of the issues were.

    Does you app show the same failure under Vista, or is it just Windows 7?
    Monday, October 12, 2009 7:36 PM
  • Hi CaptainComet,
    I have now discovered the problem is also present with Vista. There seems to be a problem with the initialfilename member of filedialog. Here is my code. On my system, users recieve pictures files via email and rename them by prefixing the filename with a job number. So a file called 'some_picture.jpg' is renamed to, for example,
    '095143 some_picture.jpg and saved into the directory named in the code below. The function is supposed (and has always done so under XP) to find only files whose names begin with the job number (SAXNUM) which is gotten from the currently open form.

    Public Function getpics()

    Dim fd As FileDialog

    Dim searchstring As String

     

    Dim RetVal as variant

    Dim vrtSelectedItem As Variant

     

     

    Set fd = Application.FileDialog(msoFileDialogOpen)

    searchstring = RTrim(Forms![MASTER FORM]![SAXNUM])

    fd.InitialFileName = "\\SERVER\C\SAXMAIN\PICTURES\" & searchstring & "*.*"

     

    With fd

     

    If .Show = -1 Then

     

    For Each vrtSelectedItem In .SelectedItems

    RetVal = Shell("EXPLORER " & vrtSelectedItem, 1)

    '.Execute   rem this has proved futile so I have commented it out (execute)

    Next vrtSelectedItem

    Else

    End If

    End With

     

    Set fd = Nothing

    End Function
    As I have said this function worked fine under XP. But now the function finds the directory OK but displays all the files!
    What do you think?
    Thanks
    Peter

    Wednesday, October 14, 2009 10:34 AM
  • I took your code and only changed the path to one of my shares on one of my servers, and the InitialFileName setting worked fine. I just copied a value into the searchstring variable.

    It worked equally well from Access 2007 on Vista64 and Access 2010 on Windows 7 RTM.

    Are you sure your RTrim function is returning what you expect?
    Wednesday, October 14, 2009 6:36 PM
  • Hello

    Please set a breakpoint on the line

    searchstring = RTrim(Forms![MASTER FORM]![SAXNUM])

    and debug the VBA (press F5).

    When the debugger breaks on the line, please step over it and check the value of searchstring.

    Regards,
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, October 15, 2009 8:26 AM
  • Hi CaptainComet,
    Yes the Rtrim function returns the correct string.
    I am now convinced the problem is in the versions of Windows. We will upgrade and I will keep you posted
    Thanks
    Peter
    Friday, October 16, 2009 5:32 AM
  • How are you? Could you please update me about your findings?


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, October 29, 2009 11:16 AM
  • We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, November 03, 2009 7:15 AM
  • Jialiang,

    I am facing a problem related to Common Dialog control in VBA.

    I have created a excel VBA which uses Common Dialog control to collect user selected *.mdb file.

    It workes fine in Windows xp. If i open the excel file with Excel 2010 beta in Windows7 OS, i am getting a error.

    The OS version is 7600.win7 rtm .090713-1255

    Plese let me know do i need to upgrade the OS to resolve the issue

     

     

    Thursday, June 10, 2010 5:30 AM