 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jesse Guest
|
Posted: Wed Sep 28, 2005 8:23 pm Post subject: Excel Worksheet selection |
|
|
I have been using the following code to initiate WorkBook & Worksheet
variables:
WBk := Excel.Workbooks.Open(Filename, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, LCID);
WS := WBk.Worksheets.Item['Sheet1'] as _Worksheet;
WS.Activate(LCID);
This has been working great EXCEPT for when the user changes the name of the
first worksheet from 'Sheet1' to something else. So, I changed that line to
read:
WS := WBk.Worksheets[1] as _Worksheet;
This seems to work on my machine, running Excel 2000, and on several other
macines running Excel 2003, but on one machine it isn't working, and I
really don't understand why. Is there a better way to initiate the
Worksheet variable irregardless of the worksheet's name, other than what
I've used here?
Thanks,
Jesse
|
|
| Back to top |
|
 |
Oliver Townshend Guest
|
Posted: Wed Sep 28, 2005 11:02 pm Post subject: Re: Excel Worksheet selection |
|
|
| Quote: | This seems to work on my machine, running Excel 2000, and on several other
macines running Excel 2003, but on one machine it isn't working, and I
really don't understand why. Is there a better way to initiate the
Worksheet variable irregardless of the worksheet's name, other than what
I've used here?
|
You can give the worksheet a name inside the VBA editor which the user can't
change (unless they go into the VBA editor as well).
You could also use the ActiveWorkSheet instead.
Oliver Townshend
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|