Greg Wilson went into some detail about what turned out to be "real" bug
with GetOpenFileName in this thread (see his last post)
http://tinyurl.com/qbr2n
and also a further follow-up here
http://tinyurl.com/ywndxd
Perhaps the sheet, which the OP says if deleted solves the problem, is
similar to Greg's as is the way the function is called.
Briefly, IsFormula type CF's that also include a worksheet function
'intermittently' cause problems (not always recreatable). One workaround,
call the function from a toolbar button.
FWIW, similar known problem with InputBox type:=8
Regards,
Peter T
"Jim Rech" wrote in message
...
Hi Art-
The MS guy took a very practical approach and gave you a workaround. It's
practical because it addressed the immediate problem of getting the result
you want and quickly. But it doesn't address why you had a problem that
never 'should' have occurred in the first place. That would leave me a
little uncomfortable because, when a workbook starts doing things it
shouldn't, I really can't trust it anymore. All I can say is, keep your
eyes pealed<g.
--
Jim
"Art" wrote in message
...
Jim,
I'm ashamed to say that I had kind of hit a road block. I actually
tried
this on 3 different, but related workbooks -- and rebuilding it seemed
really
daunting. That's what I was planning on doing when I started deleting
worksheets and copying others.
I got in touch with MS. It took me over 1 hour to get to someone that
knew
what VBA was. However, when I finally got to someone knowledable they
were
very helpful. I think they ran into the same problem with my workbook
and
eventually suggested changing the code to:
Sub temp()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.AllowMultiSelect = True
fd.Show
Set x = fd.SelectedItems
Stop
End Sub
which at least works in my test workbook on my home computer. I'm
guessing
this will work in my production file as well. Anyway I hope it does, I
really don't want to reassemble this stuff.
Thanks for taking a look!
"Jim Rech" wrote:
Can anyone give me any clues as to what's going on?
You're pulling our collective legs?<g
Might be fun to figure out what on the sheet in question is behind
this.
Not in the hopes of learning any great lesson though. I've seen
workbooks
that do weird things that were traced to the presence on one
particular,
perfectly valid formula. Delete it and recreate it and all was well.
What
do you do with that information? This could fall into that category,
but
maybe not.
--
Jim
"Art" wrote in message
...
A very weird problem...
I've got a few fairly busy workbooks, lots of sheets, lots of code.
I
added
the following code:
sub temp
dim x as variant
x=application.getopenfilename(,,,,true)
stop
end sub
When I go into immediate mode, x has a single value, one of the files
selected. If I try to look at x(1) I get an error as x does not seem
to
be
an array.
I spent over an hour trying the following:
- got rid of all of the code, except for my temp sub (still failed)
- got rid of all names in the workbook (still failed)
- got rid of all but one sheet (aha!)
- etc.
Eventually I found that if I deleted one sheet in particular, the
code
returned an array. Then I re-loaded, left the sheet in, but deleted
all
rows
and columns. It worked. I then moved, just moved, another sheet --
it
failed. I moved that other sheet around, and eventually it succeeded
and
returned an array.
Can anyone give me any clues as to what's going on?
I'm running Excel 2003(11.8134.8132) SP2