Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Barcode Label printing via Win32::OLE

by perlcgi (Hermit)
on Oct 07, 2002 at 12:46 UTC ( #203308=perlquestion: print w/replies, xml ) Need Help??

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

Hi guys, I'm trying to print a bunch of barcodes, (PNG files I created earlier with GD::Barcode), using Word and the builtin setups for Avery labels. I reckoned this would be easier than getting out a ruler and messing with HTML::Table. The following code creates a page of the appropriately sized labels, but just inserts all the barcodes into the first cell of the table, rather than a separate barcode into each cell. That's where I'm stuck. I don't have time right now to learn the Word object model, and I need the labels today. Can anyone help? TIA Perlcgi
#!perl use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 2; my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit'); $Word->{'Visible'} = 1; $Word->Documents->Add || die("Unable to create document ", Win32::OLE->LastError()); my $MyRange = $Word->ActiveDocument->Content; #Label L7651 is the one we want $Word->MailingLabel->CreateNewDocument({Name=>'L7651', Address=>"", AutoText=>"ToolsCreateLabels1", LaserTray=>wdPrinterManualFeed}); my ($row,$col)=(1,1); #Each barcode is in a separate file like 99990000.png for (my $x = 99990000; $x<99990065;$x++) { my $file = "C:\\mbc\\$x.png"; if ($col > 5) { $col = 1; $row++; } $Word->ActiveDocument->Tables(1)->Cell($row,$col)->Select; $Word->Selection->InlineShapes->AddPicture( {FileName=>$file, LinkToFile=>'False', SaveWithDocument=>'True'}); } print Win32::OLE->LastError();

Replies are listed 'Best First'.
Re: Barcode Label printing via Win32::OLE
by rdfield (Priest) on Oct 07, 2002 at 12:57 UTC
    Where is $col being incremented?

    rdfield

      Of course, how stupid of me. Thanks for taking the trouble rdfield.
      D'oh! D'oh! D'oh! D'oh!
        Can you email me some sample code of your GD::BARCODE generation and may be help me with this idea? I want to generate one barcode from a mysql database number and then print it. I am entering users in a mysql database from a web form. When I hit submit it auto-increments the member numbers. I then want to print out a bar code from the database member number and prefer to have it when I hit the submit button to add the member but would also like the option to reprint it if I like. Can you help? email is mrortner@arkbluecross.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://203308]
Approved by cacharbe
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2022-11-26 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?