Environment variables in Excel started from Win32::OLE

Discussion in 'Perl Misc' started by nicholastoze@gmail.com, Feb 15, 2007.

  1. Guest

    Hi,

    The following code only outputs 5 environment variables, not all of
    the ones I can see from perl -le 'print "$_=$ENV{$_}" for keys %ENV'.
    Is there a way to get all the environment variables in the VBA? I need
    them so that an xll can find its license key file.

    Thanks,
    Nick


    perl -v
    This is perl, v5.8.7 built for cygwin-thread-multi-64int

    uname -a
    CYGWIN_NT-5.1 PC24 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin


    Perl script:
    #!/usr/bin/perl
    use strict;
    use Win32::OLE;
    my $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});
    $ex->Workbooks->Open("C:\\test.xls", 0, 1);
    $ex->Run("printenv");


    VBA in Excel file "C:\test.xls":
    Option Explicit

    Public Sub printenv()
    Dim i As Long
    Open "C:\excelenv.txt" For Output As #1
    i = 1
    Do While Environ(i) <> ""
    Print #1, Environ(i)
    i = i + 1
    Loop
    Close #1
    End Sub
    , Feb 15, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl
    Replies:
    1
    Views:
    5,372
    Jay Tilton
    Jun 25, 2003
  2. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    177
    Jay Tilton
    Jun 25, 2003
  3. Richard S Beckett

    Win32-OLE, excel, and empties.

    Richard S Beckett, Jul 11, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    228
    Jay Tilton
    Jul 11, 2003
  4. Lance Hoffmeyer
    Replies:
    0
    Views:
    223
    Lance Hoffmeyer
    Nov 17, 2003
  5. Replies:
    1
    Views:
    794
Loading...

Share This Page