My guess is that SURR01.xls is in another directory from where your
documents are stored by default. Try putting the whole path to it in front
of the left square bracket, something like this...
Debug.Print ExecuteExcel4Macro("'C:\Dir1\Dir2\[SURR01.xls]Sheet1'!R1C1")
Replacing the C:\Dir1\Dir2 with whatever directory path your file is stored
at.
Rick
<(E-Mail Removed)> wrote in message
news:277889ab-240b-48d4-b7a9-(E-Mail Removed)...
> Hi -
>
> I'm trying to access data from a cell in a closed workbook, so I read
> previous posts about it and started with a "simplest case" test, which
> works fine:
>
>
> debug.print ExecuteExcel4Macro("'c:\[TEST.xls]Sheet1'!R1C1")
> 'yields the value of cell A1
> 'with TEST.xls as a new workbook created by me - nothing done to it
> except to add some text in cell A1
>
> BUT: when i try it with the file I actually want to access, I
> encounter problems...
>
> debug.print ExecuteExcel4Macro("'c:\[SURR01.xls]Sheet1'!R1C1")
> 'yields Error 2023
>
> However, if c:\SURR01.xls is open, ExecuteExcel4Macro does yield the
> correct results.
>
> I've triple and quadruple checked my syntax, looking for any typos,
> and Sheet1 is definitely a sheet in the workbook. So: what else
> could be different about this workbook to cause the error? It isn't
> protected. It is generated by specialized software (HP CHEMSTATION)
> but as far as I can tell is a normal (and fairly simple) excel
> workbook, nothing but text in the cells.
>
> If need be, I can easily write the program to open all the files to
> access the data, but I'm thinking somebody out there knows the answer
> to my mystery. Thanks! -Lisa
|