Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileDialog not going to folder

Status
Not open for further replies.

niteraven

Technical User
Oct 26, 2006
92
US
hello all

I have the following code, for some reason it will not go to the last folder. When button is clicked it goes to the Applications folder. I have tried a few different things and searched thru this forum and cannot find a solution. This should be simple but my brain hurts - i know that there is a space inbetween the ws and file. I have tried to use _ and still doesnt work. I have hyperlinks set up for a ton of records, so i cannot change the file folder name (WS FILE)


Any help is greatly appreciated!

Code:
Dim fd As Office.FileDialog
    Dim varfile As Variant
    Dim infilen As Variant
    
    
        infilen = "N:\Applications\WS_FILE"
        
          
          'Set up file picker dialog box
10        Set fd = Application.FileDialog(msoFileDialogFolderPicker)
20        With fd
              'do not allow users to select multiple files
30            .AllowMultiSelect = False
              
              'set the title of the dialog box
40            .TITLE = "SELECT THE WS FOLDER ASSOCIATED TO THIS RECORD"
              
             'Point to the correct path within the S Drive
50            .InitialFileName = infilen
            
              
              
60            If .Show = True Then
70                For Each varfile In .SelectedItems
80                    Me!VIEWWSMB = varfile
90                Next
100           Else
110               MsgBox "YOU CLICKED CANCEL IN THE FILE DIALOG BOX"
120           End If
130       End With

Thanks
Raven
 

You are going to hate the answer to this one...

You need to put a "\" at the end of
Code:
infilen = "N:\Applications\WS_FILE"
so it says
Code:
infilen = "N:\Applications\WS_FILE\"

That's all there is to it. It will now start 'in' the directory instead of 'at' the directory.


 
Thanks Gamma

I think i did say my brain hurt, Lord now my ego hurts. That was classic reason why this forum rocks. Always good to have a second pair of eyes. And you are right i didnt like that i missed something so simple and basic!

IT Worked!

Thanks again!
Raven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top