Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I'm trying to determine whether a cell is a formatted date or just plain text. The formatted date is stored as a variant, so I do this:
$dateVar->ChangeType(VT_BSTR)->Value();
and I extract the correct date value. However, if the cell is just plain text (no excel formatting), my program freaks out and returns to the Tk mainloop; in other words; it hangs. Can someone help? Thanks, Michael

Replies are listed 'Best First'.
Re: Excel and variants
by Jenda (Abbot) on Oct 24, 2003 at 16:11 UTC

    I guess you should test whether the $dateVar is a reference before you try to call the ChangeType(). This should be enough:

    $dateVar = $dateVar->ChangeType(VT_BSTR)->Value() if (ref $dateVar);

    You should also add a few eval {} blocks into your code and handle the exceptions gracefully.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature

      That's the stuff I needed, thanks Jenda. Michael