Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default 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 ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default 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 ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to create dbase file from text file? Hilton Excel Discussion (Misc queries) 0 October 9th 08 10:37 AM
Browse dialoge Tempy Excel Programming 2 September 20th 05 02:49 PM
Code in one workbook to call code in another XL file [email protected] Excel Programming 2 August 1st 05 03:37 PM
Import VBA Code in Excel-File ? (Export VBA Code to file) Matthias Pospiech Excel Programming 2 March 22nd 05 04:56 PM
Edit Links Dialoge Box helmekki[_39_] Excel Programming 2 October 20th 04 01:23 PM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"