GetOpenFilename

  • Thread starter Thread starter Chodu
  • Start date Start date
C

Chodu

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
 
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 *
 

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

Back
Top