Not sure what the Excel1 is supposed to represent - hopefully you are not
trying to open additional instances of Excel. Anyway, you can create a
reference to the workbook.
Dim wkbk as Workbook
iDestRow = 1
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
Excel1.Visible = True
set wkbk = Excel1.Workbooks.Open( _
Filename:=.List(i, 0), _
Format:=xlCSV, _
Delimiter:=",", _
ReadOnly:=True)
wkbk.Activate
With Wkbk.Worksheets(1)
.Range("c3").NumberFormat = "$ #,##0.00"
End With
--
Regards,
Tom Ogilvy
"exceller " wrote in message
...
Hi All,
My VB project is coming along just fine, but I'm stuck on this one
thing.. When I open files from a listbox (multiSelect) I want to call a
function to format the just opened workbooks. What happens now is that
the called function is running on the workbook containing the
macro/form.
Instead of calling the function I've written a line to activate cell
A3, which it selects on the macro/form workbook, not the just opened
workbooks as it is supposed to.
iDestRow = 1
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
Excel1.Visible = True
Excel1.Workbooks.Open _
Filename:=.List(i, 0), _
Format:=xlCSV, _
Delimiter:=",", _
ReadOnly:=True
Range("c3").Select
I've been thinking about using .List(i, 0) as a reference to activate
workbooks, but I can't find any info about activating workbooks on
variables...
If you need more code or info, please let me know!
Many thanks!
Joost
---
Message posted from http://www.ExcelForum.com/