View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Martin Los Martin Los is offline
external usenet poster
 
Posts: 12
Default Set Path for GetOpenFilename

Thanks Ron and Bernie for your contributions!

With the drive mapping I managed to solve it really
easily. I have put

ChDrive "k"

where k = "\\network\subdirectory"

The Functions Ron mentioned to might work better in the
future if I want to export the macro to other users that
are not using drive mapping.

Great help from both of you!

Both of your
-----Original Message-----
Martin,

Try using

ChDrive "Drive Name"

prior to the ChDir.

HTH,
Bernie
MS Excel MVP

"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



.