ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook references (https://www.excelbanter.com/excel-programming/280977-workbook-references.html)

Murray Williams[_3_]

Workbook references
 
When I refer to cells through VBA usually I use the
following syntax without including the .xls extension:
Workbooks("myworkbook").Worksheets("mysheet").cell s(1,1)

Two times I have gotten an error that I was able to
resolve by adding in the .xls extension to all of my
references.
Workbooks("myworkbook.xls").Worksheets("mysheet"). cells
(1,1)

One time it was on my computer that had run that
particular macro and file many times before. Today a
coworker had a problem running another macro that I and
several other of my coworkers had no problems running.

I know that I could go into all my macros and add in
the .xls extension but I would still like to understand
what is causing this. Does anyone know why? Is it a
setting within excel or something that another file that
may be open is causing?

thanks,

Murray Williams


Murray Williams[_3_]

Workbook references
 
Hate to bump this, but this is really bugging me...I'd
appreciate anyone who has any ideas to post them.

thanks,

Murray
-----Original Message-----
When I refer to cells through VBA usually I use the
following syntax without including the .xls extension:
Workbooks("myworkbook").Worksheets("mysheet").cel ls(1,1)

Two times I have gotten an error that I was able to
resolve by adding in the .xls extension to all of my
references.
Workbooks("myworkbook.xls").Worksheets("mysheet") .cells
(1,1)

One time it was on my computer that had run that
particular macro and file many times before. Today a
coworker had a problem running another macro that I and
several other of my coworkers had no problems running.

I know that I could go into all my macros and add in
the .xls extension but I would still like to understand
what is causing this. Does anyone know why? Is it a
setting within excel or something that another file that
may be open is causing?

thanks,

Murray Williams

.


Jake Marx[_3_]

Workbook references
 
Hi Murray,

This behavior has to do with whether the user has file extensions hidden for
"known" file types or not. This is an OS-level setting (available via Tools
| Folder Options in Windows Explorer). Using .xls at the end will always
work, regardless of the user's setting, so that is the preferred way to
refer to an open workbook.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Murray Williams wrote:
Hate to bump this, but this is really bugging me...I'd
appreciate anyone who has any ideas to post them.

thanks,

Murray
-----Original Message-----
When I refer to cells through VBA usually I use the
following syntax without including the .xls extension:
Workbooks("myworkbook").Worksheets("mysheet").cell s(1,1)

Two times I have gotten an error that I was able to
resolve by adding in the .xls extension to all of my
references.
Workbooks("myworkbook.xls").Worksheets("mysheet"). cells
(1,1)

One time it was on my computer that had run that
particular macro and file many times before. Today a
coworker had a problem running another macro that I and
several other of my coworkers had no problems running.

I know that I could go into all my macros and add in
the .xls extension but I would still like to understand
what is causing this. Does anyone know why? Is it a
setting within excel or something that another file that
may be open is causing?

thanks,

Murray Williams

.




All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com