Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 *** |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave, sorry for the time delay....due to different time zones
Tempy *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to create dbase file from text file? | Excel Discussion (Misc queries) | |||
Browse dialoge | Excel Programming | |||
Code in one workbook to call code in another XL file | Excel Programming | |||
Import VBA Code in Excel-File ? (Export VBA Code to file) | Excel Programming | |||
Edit Links Dialoge Box | Excel Programming |