• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Application.FileDialog(msoFileDialogFilePicker).InitialFileName

Costas

Member
Hi Chandoo,

I'm using the .InitialFileName to filter on MyLocation which can be NSW, VIC or QLD. This works fine but I also need to filter on both one location and nationwide e.g. NSW or ALL. I tried typing MyLocation &";ALL" but no joy. Here is my code:

Code:
Sub FileOpenDialogBox()
    MyPath = ThisWorkbook.Path & "\For updating\"
    ChDir MyPath
    
    With Application.FileDialog(msoFileDialogFilePicker)
          .InitialFileName = MyLocation & "_" & MySubName & "*"
          .AllowMultiSelect = False
          .Filters.Add "Excel ", "*.xlsx; *.xls", 1
          .Show
          MyFullPath = .SelectedItems.Item(1)
      End With
          Workbooks.Open FileName:=MyFullPath
          MyWbName = ActiveWorkbook.Name
          MyAnswer = vbYes
End Sub

Is there a way to do that?

Thanks
Costas
 
Hi vletm,

Thanks for your reply.

I followed the link and tried it but couldn't get it to work. I understand the loop but don't know how to get it to see the the different cases (e.g. NSW or ALL). I'm not sure if the example is incomplete or if I'm not getting it. Can you please spell it out a bit more?

Cheers
Costas
 
Costas
Could You reread Your one of previous thread:
Could You do/use two codes ... one for 'one location' and other one for other 'nationwide'?
 
Hi vlerm,

I can't see how the previous post is relevant to what I'm trying to do. Maybe I wasn't clear enough so it's best if I give an example.
If in a folder I have some files starting with NSW_* and some others starting with VIC_* and others with QLD_* and others starting with ALL_*.

If MyLocation = "NSW" then what I'm after is for the file open dialogue to filter only on NSW and ALL files.
If MyLocation = "VIC" then what I'm after is for the file open dialogue to filter only on VIC and ALL files.

Hope this make sense.
 
Vletm,

Do you have a specific code to give instead of a reference?

I don't want to waste anyone's time here.

Thanks
Costas
 
Back
Top