![]() |
Help with - Get File dialoge code
Hello all, i am using the code below to open a dialog to retrieve a file
and it works great if i name the drive letter, howver i need to put in the server IP, as not all users log the drive on the same letter. The path enclosed in brackets is the path i need to point to. Could somebody please help with this code. Sub TestGet() ChDrive "c" (" \\zapad01\sapinter ") ChDir "C:\Documents and Settings\Stoutle\SapWorkDir" ("\\zapad01\sapinter\ZA-TM-RECON\UPLOAD") fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If End Sub Thanks in advance Tempy *** Sent via Developersdex http://www.developersdex.com *** |
Help with - Get File dialoge code
The chdrive won't work on network drives.
But you can use an API call: Option Explicit Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Sub ChDirNet(szPath As String) Dim lReturn As Long lReturn = SetCurrentDirectoryA(szPath) If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path." End Sub Sub testme02() Dim mySavedPath As String mySavedPath = CurDir ChDirNet "\\zapad01\sapinter\ZA-TM-RECON\UPLOAD" 'do your stuff ChDirNet mySavedPath End Sub This actually works with mapped drives, too. Tempy wrote: Hello all, i am using the code below to open a dialog to retrieve a file and it works great if i name the drive letter, howver i need to put in the server IP, as not all users log the drive on the same letter. The path enclosed in brackets is the path i need to point to. Could somebody please help with this code. Sub TestGet() ChDrive "c" (" \\zapad01\sapinter ") ChDir "C:\Documents and Settings\Stoutle\SapWorkDir" ("\\zapad01\sapinter\ZA-TM-RECON\UPLOAD") fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If End Sub Thanks in advance Tempy *** Sent via Developersdex http://www.developersdex.com *** -- Dave Peterson |
Help with - Get File dialoge code
Thanks Dave, sorry for the time delay....due to different time zones
Tempy *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 02:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com