Results 1 to 4 of 4

Thread: Application FileDialog problem

  1. #1
    Join Date
    Feb 2008
    Posts
    2,180

    Application FileDialog problem

    I have a macro that uses a graphical interface. On this interface, I use 2 buttons that allow me to select specific files.

    The problem is that once I use the first, it saves the file type and I once again each time the same file type as it should change. I have not understand? So here's an example!

    I launch the application and click on the button that 2 is used to select a file type "*.spe". I selected my file without problem. I click the button 4, which I use to select files of type "*.lcs" and it offers me the file type "*.spe". I need to change each time the file type and that commence me inflate serious (especially behind that, it can cause a lot of mistakes! )

    Here is the code!

    Code:
    Private Sub CommandButton4_Click () 
    MsgBox ("Warning: the address must not contain spaces") 
    Dim fdChoice As FileDialog 
    Dim strNamefile As String 
    Set fdChoice = Application.FileDialog (msoFileDialogFilePicker) 'choose file 
    fdChoice.ButtonName = 'Choose' button name 
    fdChoice.Title = "Select a file.lcs" 'under the box 
    fdChoice.Filters.Add "Files.lcs", "*.lcs' filter files 
    fdChoice.InitialFileName = "H:" 'original record 
    fdChoice.AllowMultiSelect = False 'no multi selection 
    If fdChoice.Show = False Then 
    MsgBox "Setting aside" 
    Exit Sub 
    Else 
    strNamefile = fdChoice.SelectedItems (1) 'store the file name selected 
    Me.TextBox2.Value = strNamefile 
    MsgBox (strNamefile & "selected") 'treatment 
    End If 
    End Sub 
    Private Sub CommandButton2_Click () 
    MsgBox ("Warning: the address must not contain spaces") 
    Dim fdChoiceSpe As FileDialog 
    Dim strNamefileSpe As String 
    Set fdChoiceSpe = Application.FileDialog (msoFileDialogFilePicker) 'choose file 
    fdChoiceSpe.Title = "Choose the file spe" 'under the box 
    fdChoiceSpe.Filters.Add "spe Files", "*.spe" 'filter files 
    fdChoiceSpe.InitialFileName = "H:" 'original record 
    fdChoiceSpe.AllowMultiSelect = False 'no multi selection 
    If fdChoiceSpe.Show = False Then 
    MsgBox "Setting aside" 
    Exit Sub 
    Else 
    strNamefileSpe = fdChoiceSpe.SelectedItems (1) 'store the file name selected 
    Me.TextBox1.Value = strNamefileSpe 
    MsgBox (strNamefileSpe & "selected") 'treatment 
    End If 
    End Sub

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: Application FileDialog problem

    According to the docs, there is an additional parameter optional Filters.Add which is an instance number. So maybe you should try:
    Code:
    fdChoice.Filters.Add "Files.lcs", "*.lcs" 10 
    ... 
    fdChoiceSpe.Filters.Add "spe Files", "*.spe", 11

  3. #3
    Join Date
    Feb 2008
    Posts
    2,180

    Re: Application FileDialog problem

    The parameter in question is an address? I get the following message

    "Error 9 The index is not a selection... "

  4. #4
    Join Date
    May 2008
    Posts
    945

    Re: Application FileDialog problem

    Hi, place

    Code:
    fdChoice.Filters.Clear
    and

    Code:
    fdChoiceSpe.Filters.Clear
    to suitable locations

Similar Threads

  1. Facebook application problem in C3
    By Orrin in forum Portable Devices
    Replies: 2
    Last Post: 27-11-2010, 05:44 AM
  2. VBScript: how to open FileDialog always on top (Vista)
    By kaviyesh in forum Software Development
    Replies: 4
    Last Post: 21-10-2010, 04:44 PM
  3. Problem while installing an application on E72.
    By Gimelstob in forum Portable Devices
    Replies: 6
    Last Post: 04-06-2010, 11:27 AM
  4. Use of FileDialog class
    By Gadin in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 08:39 AM
  5. WinDVD MFC Application has encountered a problem
    By CitricAcid in forum Operating Systems
    Replies: 3
    Last Post: 22-07-2009, 11:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,656,052.73590 seconds with 16 queries