0

I'm testing out a user app that they will be accessing remotely. There is file dialog functionality that I've included using the FileDialog object. I'd like for them to initially open up their own local files using the property .InitialFileName, but I'm having trouble finding the correct path for the initial open. Here's what I have so far:

Dim fileDialog As Object 'Office.FileDialog
  Set fileDialog = Application.fileDialog(msoFileDialogFilePicker)
  With fileDialog
    .InitialFileName = "C on " & Environ("CLIENTNAME")
    ....

When I do open up the dialog without setting the initial file path, there is a location that the user can access that is ""C on PCName", so I thought that I could just set the string to be the same (in above code), but it doesn't work if I set that as the path. Environ("CLIENTNAME") does get the PCName of the user, so I think I am close to a solution.

Thanks for any suggestions.

Pflipper
  • 88
  • 6

2 Answers2

0

There is a list of potentially useful environment variables here

This might be a starting point

Option Explicit

Sub x()


Dim fileDialog As Object 'Office.FileDialog
  Set fileDialog = Application.fileDialog(msoFileDialogFilePicker)
  With fileDialog
    .InitialFileName = Environ("HOMEPATH")
        .Show
    End With
End Sub

JohnnieL
  • 1,192
  • 1
  • 9
  • 15
  • Thanks for the reply. I think that Environ("HOMEPATH") just gets the user's local path on the server that they are remoting into. I need the remote user's local path, the one on the PC they are using to connect to the remote server. I did wind up finding a solution - use "\tsclient\c" to get the remote user's local C to open up in the file dialog. – Pflipper Feb 25 '21 at 19:40
  • I think you could improve your response-chance and perhaps get a less hard-coded solution by changing the tags: I would phrase the question something like "how do i get user home environment variable for RDP[or whatever app you are using]" - your question isnt about the filedialog or vba its about the remote client environment - just a thought - good luck – JohnnieL Feb 25 '21 at 19:52
0

Never mind. I do believe I've come across a solution:

FileDialog.InitialFileName = "\tsclient\c"

Pflipper
  • 88
  • 6