Get Open File NAme

G

Guest

I am having a problem using getopenfilename function. It runs OK the first
time, but when I go to re-run this routine it does not return an "array" and
the routing does not run a second time.

Can't figgure out the behavior. Has anyone seen this?

++++++++++++++++++++++++++++++++++++++++++++++++
fileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls", , , ,
True)

If IsArray(fileToOpen) Then ' if no files selected, then do nothing,
otherwise, run the routines below

***** AND THEN I MANIPULATE THE DATA HERE *****

fileToOpen.Close
End If
 
R

RadarEye

I am having a problem using getopenfilename function. It runs OK the first
time, but when I go to re-run this routine it does not return an "array" and
the routing does not run a second time.

Can't figgure out the behavior. Has anyone seen this?

++++++++++++++++++++++++++++++++++++++++++++++++
fileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls", , , ,
True)

If IsArray(fileToOpen) Then ' if no files selected, then do nothing,
otherwise, run the routines below

***** AND THEN I MANIPULATE THE DATA HERE *****

fileToOpen.Close
End If

Hi JimBob,

Try this:

Sub ProcessFile()
Dim fileToOpen As String

fileToOpen = Application.GetOpenFilename("Excel files (*.xls),
*.xls")

If fileToOpen <> "False" Then
' DO THIS AND THAT
End If

End Sub

HTH,

Wouter
 
R

Ron de Bruin

Hi

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName <> False Then
Workbooks.Open (FName)
End If


If you use multiselect then use the array like this

FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xl*", _
MultiSelect:=True)

If IsArray(FileNameXls) = False Then
'do nothing
Else
'Your code
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top