ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get Open File NAme (https://www.excelbanter.com/excel-programming/392027-get-open-file-name.html)

Jimbob

Get Open File NAme
 
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

RadarEye

Get Open File NAme
 
On 25 jun, 21:26, JimBob wrote:
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


Ron de Bruin

Get Open File NAme
 
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



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"JimBob" wrote in message ...
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


Ron de Bruin

Get Open File NAme
 
hi RadarEye

Use False instead if "False" to avoid international problems

See
http://www.oaltd.co.uk/ExcelProgRef/default.htm

Read the International Issues chapter of the book

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"RadarEye" wrote in message ups.com...
On 25 jun, 21:26, JimBob wrote:
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



All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com