cannot create Excel QueryTable object with perl

R

robert.paschedag

Hi,

I'm trying to import some data into Excel with Perl. My Problem is,
that I cannot create an object of a type "QueryTable"

use strict;
use Win32::OLE 'with';
use Win32::OLE::Variant;

my ($app, $obj, $book, $sheet, $file, $table);

my $conn = 'TEXT;C:\\temp\\uni_source_target_language.csv';
my $variant_conn = Variant(VT_BSTR, $conn);

$app = Win32::OLE->new('Excel.Application', \&OLE_Quit) or die
"oops\n";

$book = $app->Workbooks->Add;
$sheet = $book->ActiveSheet;
$app->{Visible} = 1;

$table = $sheet->QueryTables->Add(Connection => $variant_conn,
Destination => $sheet->Range("A1"));

exit(0);

Subroutine .....

The $table is always "undef". What am I doing wrong?

pasche
 
M

Matt Garrish

Hi,

I'm trying to import some data into Excel with Perl. My Problem is,
that I cannot create an object of a type "QueryTable"

use strict;
use Win32::OLE 'with';
use Win32::OLE::Variant;

$Win32::OLE::Warn = 3;

It should explain the problem.

Matt
 
M

Matt Garrish

Hi,

I'm trying to import some data into Excel with Perl. My Problem is,
that I cannot create an object of a type "QueryTable"

use strict;
use Win32::OLE 'with';
use Win32::OLE::Variant;

my ($app, $obj, $book, $sheet, $file, $table);

my $conn = 'TEXT;C:\\temp\\uni_source_target_language.csv';
my $variant_conn = Variant(VT_BSTR, $conn);

$app = Win32::OLE->new('Excel.Application', \&OLE_Quit) or die
"oops\n";

$book = $app->Workbooks->Add;
$sheet = $book->ActiveSheet;
$app->{Visible} = 1;

$table = $sheet->QueryTables->Add($variant_conn, $sheet->Range("A1"));

Add takes a list, not a hash. See my other post for more info on how to help
yourself by getting error messages.

Matt
 
R

robert.paschedag

Matt said:
$table = $sheet->QueryTables->Add($variant_conn, $sheet->Range("A1"));

Add takes a list, not a hash. See my other post for more info on how to help
yourself by getting error messages.

Matt

Hi Matt,

thanks! Now I get an object, but now the "Refresh" Method does not seem
to work. I do not see the imported data in the worksheet. Perhaps you
can also help me here. Meanwhile I'll try my self.

Pasche
 
M

Matt Garrish

thanks! Now I get an object, but now the "Refresh" Method does not seem
to work. I do not see the imported data in the worksheet. Perhaps you
can also help me here. Meanwhile I'll try my self.

Please post another snippet of code displaying the problem (even if it's
just another line or two). I won't be able to help unless I can see what
you're doing.

Matt
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top