|
|
COM access to Excel: Avoid directly subscripting a collection
Another example of when it is dangerous to assume a VBA syntax in
using the COM interface:
>> xlApp.ActiveSheet.Range('A2:B3').Rows(1).Address
ans =
$A$2:$B$3
>> xlApp.ActiveSheet.Range('A2:B3').Rows.Item(1).Address
ans =
$A$2:$B$2
Anyway, in case anyone is googling this, it seems like an important
"best practice".
|
|
0
|
|
|
|
Reply
|
paul.domaskis (115)
|
6/3/2012 12:45:26 AM |
|
On Jun 2, 8:45 pm, Paul <paul.domas...@gmail.com> wrote:
> Another example of when it is dangerous to assume a VBA syntax in
> using the COM interface:
>
> >> xlApp.ActiveSheet.Range('A2:B3').Rows(1).Address
>
> ans =
> $A$2:$B$3>> xlApp.ActiveSheet.Range('A2:B3').Rows.Item(1).Address
>
> ans =
> $A$2:$B$2
>
> Anyway, in case anyone is googling this, it seems like an important
> "best practice".
Actually, this works too. xlApp.Selection.get('Rows',1).Address
It's unfortunate, this ambiguity in the syntax that can lead to a bit
of guesswork in coding. I find myself constantly having to lookup my
own code to ensure that I'm not taking a mis-step. It probably can't
be avoided, because we're talking two different languages (matlab and
VBA or COM), so it boils down to capturing best practices regarding
what works and what doesn't.
|
|
0
|
|
|
|
Reply
|
paul.domaskis (115)
|
6/3/2012 1:05:20 AM
|
|
|
1 Replies
36 Views
(page loaded in 0.038 seconds)
Similiar Articles: Adding simple database, excel export, and reports with D4 Pro ...... be a CSV format which is directly usable by Excel and Access. ... some opinions and advice to avoid ... every access of the collection item returned from inherited access to ... The nightmare begins... - comp.databases.filemakerAnd it lacks what would make it a simple data collection ... I've almost always avoid programming when I can simply ... most people do not know any better, they use excel for ... Copy Files with long file names - comp.databases.ms-access ...Or, if the FSO has a collection where you could access the files by ... data by sight - obviously something to avoid ... USB drive, rather than copying the files directly. Intel Visual Fortran Error Message - comp.lang.fortranHello, I' working on another of a large collection of ... also get you notices of product updates and access to ... I don't show it directly because I will get flooded ... how does this thing work?! - comp.databases.filemakerThe whole point of the ID field is to avoid creating ... about the amount of stuff that is done within e.g. Excel. ... doesn't think like a little SQL Server or even Access ... What's the deal with Monotype Sorts in MS Office - comp.fonts ...... is a valid approach, you might contact MS directly ... one Office version to another, in part, to prevent ... with MS applications including Access 2000, Access 97 SR2, Excel ... How best to detect duplicate values in a column? - comp.databases ...... to shrink the window to a 2-inch-wide column to avoid ... Problem is, you need to access the data the same way you ... comp.soft-sys.sas How to Delete Duplicate Rows in Excel ... Is Cambria a standard Windows font everyone has? - comp.fonts ...... supply this font Product Name Font Version Excel ... To avoid the proprietary Word format while preserving ... Vista, Microsoft included the ClearType Font Collection ... Where did Fortran go? - comp.lang.fortran... all NaN cases properly, but avoid ... I didn't even have handy access to them ... for example, it is so difficult for excel to >interact with fortran (either directly ... Thread Subject: COM access to Excel: Avoid directly subscripting a ...Thread Subject: COM access to Excel: Avoid directly subscripting a collection ... Another example of when it is dangerous to assume a VBA ... Topic: COM access to Excel: Avoid directly subscripting a collectionViews expressed in these public forums are not endorsed by Drexel University or The Math Forum. 7/2/2012 10:20:16 AM
|
|
|
|
|
|
|
|
|