Posts 1 - 10 of 14
First | Prev. | 1 2 | Next | Last
|
|
Peter Sippel
Guest
|
Hi,
I have two questions:
1. How can I determine if a whole row is selected
2. How can I walk through multiple selected rows, for example:
I have 8 rows selected, but in multiple sequences:
3 rows selected
2 rows NOT selected
4 rowse selected
3 rows NOT selected
1 row selected
Thanks in Advance.
Peter |
|
Posted 02 Dec, 2011 08:21:02
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Hi Peter,
Is it Excel? Or a Word table?
Are you talking about selecting uncontigous areas?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 02 Dec, 2011 08:30:59
|
|
Top
|
|
Peter Sippel
Guest
|
oh, sorry, it's Excel. And yes, it's uncontiguous areas. |
|
Posted 02 Dec, 2011 08:44:55
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Try casting ExcelApp.Selection to ExcelRange. Selected areas are listed in ExcelRange.Areas; an area is of the ExcelRange type, too. If a row is selected, Range.Address in VBA returns "$4:$4" or "$4:$6" if the row 4 or rows 4 through 6 are selected. If you select columns, you get "$D:$D" or "$B:$D" instead.
Hope this helps.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 02 Dec, 2011 09:16:56
|
|
Top
|
|
Peter Sippel
Guest
|
Hi Andrei,
Address has Parameters:
- RowAbsolute
- ColumnAbsolute
- ReferenceStyle
- External
- RelativeTo
I don't know how to call this function.....
ExcelApp.Selection is an array of IDispatch. But the following doesn't work:
er := ExcelRange(ExcelApp.ActiveWindow.Selection);
for i := 0 to er.Areas.Count - 1 do
ShowMessage( Format( '%d rows selected',[er.Areas[i].Rows.Count] ) );
or
ShowMessage( Format( '%d rows selected',[er.Areas.Item[i].Rows.Count] ) );
So, still I need to know how to walk through the selected rows...
Thanks
Peter |
|
Posted 02 Dec, 2011 09:59:52
|
|
Top
|
|
Peter Sippel
Guest
|
Ah, it's Base 1. With
for i := 1 to er.Areas.Count do
ShowMessage( Format( '%d rows selected / %s',
[er.Areas[i].Rows.Count, er.Areas[i].Address[False, False, xlA1, EmptyParam, EmptyParam] ] ) );
it works.
Thanks.
Peter |
|
Posted 02 Dec, 2011 10:15:25
|
|
Top
|
|
Peter Sippel
Guest
|
But still I would like to know what's the best way to determine that a whole row has been selected. I could check the selected columns to their maximum value (16384 in my Outlook Version). Is there a global information what's the maximum number of columns and rows ?
And how can I access the actual cell values ? |
|
Posted 02 Dec, 2011 10:32:25
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Hello,
You can check if the string retruned by ExcelRange.Address[False, False, xlA1, EmptyParam, EmptyParam] is in the "4:4" or "4:6" format; ExcelRange.Address[True, True, xlA1, EmptyParam, EmptyParam] returns "$4:$4" or "$4:$6".
Andrei Smolin
Add-in Express Team Leader |
|
Posted 02 Dec, 2011 11:27:57
|
|
Top
|
|
Peter Sippel
Guest
|
Address returns 4:4 format, that's fine for me. But what about the actual cell values, meaning the text in the cells of a specific row, e.g. row4, col1 / row4, col2 etc. ?
Edit ==>
Got it, range.cells.value[row,col]
So last open question is variable for max rows and cols... |
|
Posted 02 Dec, 2011 11:50:22
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
|
Posted 03 Dec, 2011 04:12:06
|
|
Top
|
|
Posts 1 - 10 of 14
First | Prev. | 1 2 | Next | Last
|