View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Set Path for GetOpenFilename

Hi Martin

'Previously posted by Rob Bovey:

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

' sample usage

Sub FindFile()
Dim FName As Variant

ChDirNet "\\DELL\testing"
FName = Application.GetOpenFilename
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Martin Los" wrote in message ...
I want to set the path to a network for the following
macro:

Sub OpenMultipleFiles()
Dim fn As Variant, f As Integer
Dim MyPath As String

MyPath = "\\network\subdirectory\"
ChDir MyPath
fn = Application.GetOpenFilename("Excel-files,*.xls", _
1, "Select one or more files to open", , True)
If TypeName(fn) = "Boolean" Then Exit Sub
For f = 1 To UBound(fn)
Debug.Print "Selected file #" & f & ": " & fn(f)
Workbooks.Open fn(f)
MsgBox ActiveWorkbook.Name, , "Active Workbook
Name:"
ActiveWorkbook.Close False
' close the active workbook without saving any
changes
Next f
End Sub

However, the GetOpenFilename dialog does NOT go to the
network. Can anybody tell me how to solve this?

TIA

Martin