The Quickbooks SDK has an excellent online reference manual for how to write custom programs to manipulate quickbooks. The manual links to a blog post demonstrating how to control quickbooks from Java. Below I post a Perl transliteration of the java code.
#!/usr/bin/perl use Data::Dumper; use IO::File; use XML::LibXML; use XML::LibXSLT; use Win32::OLE::Const; Win32::OLE->Option(Warn => 2); use strict; my $appname='Test App'; my $qbfile=''; main(); sub main { my $const = Win32::OLE::Const->Load("QBXMLRP2 1.0 Type Library"); my $session = Win32::OLE->new("QBFC10.QBSessionManager", sub {$_[0] +->CloseConnection();}) or die "oops\n"; $session->OpenConnection2("", $appname, $const->{"localQBD"}); my $ticket = $session->BeginSession($qbfile, $const->{"qbFileOpenDoN +otCare"}); my $msgSet = $session->CreateMsgSetRequest('US',3,0); $msgSet->AppendVendorQueryRq; my $resSet = $session->DoRequests($msgSet); my $resList = $resSet->ResponseList; my $count = $resList->Count; for (my $i=0; $i < $count; ++$i) { warn $i; my $res = $resList->GetAt($i); my $vendList = $res->Detail; warn Dumper($vendList); my $vcount = $vendList->Count; for (my $j=0; $j < $vcount; ++$j) { my $vend = $vendList->GetAt($j); my $dname = $vend->Name; my $name = $dname->GetValue; warn "Vendor name: $name"; } } $session->EndSession; $session->CloseConnection; warn "Goodbye World!"; }




The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

Replies are listed 'Best First'.
version using qbXML
by metaperl (Curate) on Jun 10, 2011 at 18:41 UTC
    #!/usr/bin/perl use strict; use warnings; use IO::File; use XML::LibXML; use XML::LibXSLT; use Win32::OLE::Const; Win32::OLE->Option(Warn => 2); use File::Slurp; use XML::TreeBuilder; my $name_reported_to_quickbooks = "Test App"; my $qb_company_file = ""; my $request_xml_file = "vendor_query.xml"; my $stylesheet_file = "update_bill_line_item_account.xslt"; main(); sub main { my $qbxmlrp_const = Win32::OLE::Const->Load("QBXMLRP2 1.0 Type Libra +ry"); my $request_processor = Win32::OLE->new("QBXMLRP2.RequestProcessor", + sub {$_[0]->CloseConnection();}) or die "oops\n"; $request_processor->OpenConnection2("", $name_reported_to_quickbooks +, $qbxmlrp_const->{"localQBD"}); my $ticket = $request_processor->BeginSession($qb_company_file, $qbx +mlrp_const->{"qbFileOpenDoNotCare"}); my $request_xml_string = File::Slurp::read_file($request_xml_file); my $response_xml_string = $request_processor->ProcessRequest($ticket +, $request_xml_string); my $tree = XML::TreeBuilder->new({ 'NoExpand' => 0, 'ErrorContext' = +> 0 }); # empty tree $tree->parse($response_xml_string); my @node = $tree->look_down('_tag' => 'Name'); for my $node (@node) { warn $node->content_list; } } # Read the contents of a file into a string. # Accepts filename as a parameter and returns the file contents. sub read_file($) { my $filename = shift; my $file_data; local($/) = undef; my $file_handle = IO::File->new(); $file_handle->open($filename); $file_data = <$file_handle>; $file_handle->close(); return $file_data; }
    <?xml version="1.0"?> <?qbxml version="10.0"?> <QBXML> <QBXMLMsgsRq onError="continueOnError"> <VendorQueryRq> </VendorQueryRq> </QBXMLMsgsRq> </QBXML>




    The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

    -- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

Re: Control Windows Quickbooks with Win32::OLE
by jbryan (Acolyte) on Jan 30, 2014 at 20:47 UTC

    I don't know if anyone is going to see this, but I'm having a heckuva time getting this working - primarily because it fails with a "Class not registered" message (stacktrace below) - I'm assuming that means that the "QBXMLRP2.RequestProcessor" OLE class isn't registered. But I have installed QuickBooks SDK 11.0 - and uninstalled and reinstalled just to be sure. Still doesn't work. I've worked with the QB SDK before - about 3 years ago - so I know this *Should* work - but it's not. Any ideas on how to get this to work?

    E:\JBI\devel>perl test1.pl Win32::OLE(0.1709) error 0x80040154: "Class not registered" at test1.p +l line 29. eval {...} called at test1.pl line 29 main::main() called at test1.pl line 21 oops
Re: Control Windows Quickbooks with Win32::OLE
by metaperl (Curate) on Nov 19, 2011 at 06:40 UTC
    Cleaned up the code even more:
    #!/usr/bin/perl use strict; use warnings; use Win32::OLE::Const; Win32::OLE->Option( Warn => 2 ); use File::Slurp; use XML::TreeBuilder; my $rand = rand 999999999; my $app_name = "Test $rand"; # http://www.devx.com/xml/Article/30482/1763/page/2 # only relevant if you develop software for QuickBooks that you intend + to sell to other parties. my $app_id = ''; my $qb_company_file = ""; my $request_xml_file = "vendor_query.xml"; main(); sub main { my $qbxmlrp_const = Win32::OLE::Const->Load("QBXMLRP2 1.0 Type Lib +rary"); my $request_processor = Win32::OLE->new( "QBXMLRP2.RequestProcessor", sub { $_[0]->CloseConnection(); } ) or die "oops\n"; $request_processor->OpenConnection2( $app_id, $app_name, $qbxmlrp_const->{"localQBD"} ); my $ticket = $request_processor->BeginSession( $qb_company_file, $qbxmlrp_const->{"qbFileOpenDoNotCare"} ); my $request_xml_string = File::Slurp::read_file($request_xml_file) +; my $response_xml_string = $request_processor->ProcessRequest( $ticket, $request_xml_string + ); warn $response_xml_string; } # # Read the contents of a file into a string. # # Accepts filename as a parameter and returns the file contents. # sub read_file($) { # my $filename = shift; # my $file_data; # local ($/) = undef; # my $file_handle = IO::File->new(); # $file_handle->open($filename); # $file_data = <$file_handle>; # $file_handle->close(); # return $file_data; # }




    The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

    -- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"