Environment variables in Excel started from Win32::OLE

N

nicholastoze

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top