Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Small problem with GetopenFileName

Good morning all!

I want to be able to let the user select multiple files from a
GetOpenFileName dialog box, but also filter the file list to Excel files only
and trap for the user pressing Escapel.

If I use:

SAPDataWorkbook = Application.GetOpenFilename()
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

I can press escape OK AND open a workbook

If however I change the first line thus:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

to filter to *.xls I can press escape, but get the message "Type mismatch"
with

If SAPDataWorkbook = False Then

highlighted.

Can anyone out there help, please?

Thanks in advance

Pete

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Small problem with GetopenFileName

I assume you have
Dim SAPDataWorkbook As String

If you read the help you will see "If MultiSelect is True, the return value
is an array of the selected file names (even if only one filename is
selected). "
Hence change it to: Dim SAPDataWorkbook As Variant

NickHK

"Peter Rooney" wrote in message
...
Good morning all!

I want to be able to let the user select multiple files from a
GetOpenFileName dialog box, but also filter the file list to Excel files

only
and trap for the user pressing Escapel.

If I use:

SAPDataWorkbook = Application.GetOpenFilename()
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

I can press escape OK AND open a workbook

If however I change the first line thus:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

to filter to *.xls I can press escape, but get the message "Type mismatch"
with

If SAPDataWorkbook = False Then

highlighted.

Can anyone out there help, please?

Thanks in advance

Pete



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Small problem with GetopenFileName

Hi, Nick,

No, I thought of that - it's declared as Variant already :-(

Pete


"NickHK" wrote:

I assume you have
Dim SAPDataWorkbook As String

If you read the help you will see "If MultiSelect is True, the return value
is an array of the selected file names (even if only one filename is
selected). "
Hence change it to: Dim SAPDataWorkbook As Variant

NickHK

"Peter Rooney" wrote in message
...
Good morning all!

I want to be able to let the user select multiple files from a
GetOpenFileName dialog box, but also filter the file list to Excel files

only
and trap for the user pressing Escapel.

If I use:

SAPDataWorkbook = Application.GetOpenFilename()
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

I can press escape OK AND open a workbook

If however I change the first line thus:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

to filter to *.xls I can press escape, but get the message "Type mismatch"
with

If SAPDataWorkbook = False Then

highlighted.

Can anyone out there help, please?

Thanks in advance

Pete




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Small problem with GetopenFileName

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If Not IsArray(SAPDataWorkbook) Then
MsgBox "Nothing selected"
Else
For i = LBound(SAPDataWorkbook) To UBound(SAPDataWorkbook)
Workbooks.Open Filename:=SAPDataWorkbook(i)
Next i
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Peter Rooney" wrote in message
...
Good morning all!

I want to be able to let the user select multiple files from a
GetOpenFileName dialog box, but also filter the file list to Excel files

only
and trap for the user pressing Escapel.

If I use:

SAPDataWorkbook = Application.GetOpenFilename()
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

I can press escape OK AND open a workbook

If however I change the first line thus:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

to filter to *.xls I can press escape, but get the message "Type mismatch"
with

If SAPDataWorkbook = False Then

highlighted.

Can anyone out there help, please?

Thanks in advance

Pete



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Small problem with GetopenFileName

Thanks a lot Bob! :-)

Pete


"Bob Phillips" wrote:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If Not IsArray(SAPDataWorkbook) Then
MsgBox "Nothing selected"
Else
For i = LBound(SAPDataWorkbook) To UBound(SAPDataWorkbook)
Workbooks.Open Filename:=SAPDataWorkbook(i)
Next i
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Peter Rooney" wrote in message
...
Good morning all!

I want to be able to let the user select multiple files from a
GetOpenFileName dialog box, but also filter the file list to Excel files

only
and trap for the user pressing Escapel.

If I use:

SAPDataWorkbook = Application.GetOpenFilename()
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

I can press escape OK AND open a workbook

If however I change the first line thus:

SAPDataWorkbook = Application.GetOpenFilename( _
filefilter:="Excel Files (*.xls),*.xls", MultiSelect:=True)
If SAPDataWorkbook = False Then
Exit Sub
End If
Workbooks.Open Filename:=SAPDataWorkbook

to filter to *.xls I can press escape, but get the message "Type mismatch"
with

If SAPDataWorkbook = False Then

highlighted.

Can anyone out there help, please?

Thanks in advance

Pete




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
small problem PH NEWS Excel Worksheet Functions 7 March 22nd 06 07:15 PM
Problem with application.getopenfilename Andy TB Excel Programming 2 March 3rd 06 01:29 PM
A small problem for you but big for me! Michael Excel Discussion (Misc queries) 4 June 28th 05 06:38 AM
Problem with small()....I think Weekend user Excel Worksheet Functions 5 May 16th 05 11:21 AM
GetOpenFilename - Problem Tom Excel Programming 2 August 4th 03 07:52 PM


All times are GMT +1. The time now is 08:40 PM.

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

About Us

"It's about Microsoft Excel"