Thread: GetOpenFilename
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default GetOpenFilename

Hi Chodu,

Here's an example of one way to make this work.

Sub OpenMultipleFiles()
Dim vaFileNames As Variant
Dim vItem As Variant
vaFileNames = Excel.Application.GetOpenFilename( _
"XLS (*.xls), *.xls", , "Open All Files Here", , True)
' If the result is not an array the user cancelled
' the dialog.
If IsArray(vaFileNames) Then
For Each vItem In vaFileNames
Excel.Application.Workbooks.Open vItem
Next vItem
End If
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Chodu" wrote in message
...
I want the user to open multiple Excel files at once (if
possible, all files in a specific directory.

Since my code is in access, I'm using the following method:
Excel.Application.GetOpenFilename("XLS (*.xls),
*.xls", , "Open All Files Here", , True)

I know that since multiple select is true, this code will
return an array with all of the file names. I just don't
know how to assign a reference to this array so that I can
open all of the workbooks.

TIA
Chodu