Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Excelís Select and Activate considered harmful

by moritz (Cardinal)
on Mar 02, 2011 at 11:46 UTC ( #890964=note: print w/ replies, xml ) Need Help??


in reply to Excelís Select and Activate considered harmful

So when I want to automate something, and the macro recorder uses Select, how do I rewrite it not to use Select?

It's good to warn against harmful practise, but if you offer no alternatives, your effort will most likely be lost.


Comment on Re: Excelís Select and Activate considered harmful
Replies are listed 'Best First'.
Re^2: Excelís Select and Activate considered harmful
by davies (Vicar) on Mar 02, 2011 at 11:52 UTC

    Create your own object and assign to that. To give an example, instead of

    $sht->Range("A1")->Select;
    use
    my $rng = $sht->Range("A1");
    Then, rather than Selection->, use $rng->. Obviously, it's better to use a descriptive name rather than $rng.

    Regards,

    John Davies

Re^2: Excelís Select and Activate considered harmful
by dasgar (Curate) on Mar 04, 2011 at 06:29 UTC

    Usually in the code that I've written, I'm interested in reading from or writing to a cell and I don't need or want to keep a reference around for that cell. In my case, I just skip the selection step altogether with code like:

    my $value = $sht->Range("A1")->{Value};

    or

    $sht->Range("A1")->{Value} = $value;

    Just tossing out a suggestion (hopefully a correct and useful one) about how to avoid using Select.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://890964]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (13)
As of 2015-07-30 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls