The "Unable..." message is my die alternative to system (take a look at the first post). The "1 file copied..." and "No such file..." messages are standard DOS messages (I've just translated them from my native language, portuguese). Here's the source code who generated the two files, sorry I couldn't translate the portuguese messages, but you should understand the code (I've putted some comments tough...). Thanks a lot for your help.
#!/usr/bin/perl -w use strict; use Win32::OLE; use Tk; use Tk::DialogBox; my $mw = MainWindow->new( -width => 350, -title => 'Gerenciador de Planilhas', -height => 50 ); my $Frame0 = $mw->Frame(); $Frame0->place( -x => 0, -y => 8, -height => 54, -width => 352); #the following button activates the sub that generates the document my $Button1 = $mw->Button( -text => "Criar Planilha", -relief => "raised", -command => \&geraNova ); $Button1->place( -x => 9, -y => 14, -height => 25, -width => 74); my $Button2 = $mw->Button( -text => "Sobre...", -relief => "raised", -command => \&onAbout ); $Button2->place( -x => 203, -y => 14, -height => 25, -width => 64); my $Button3 = $mw->Button( -text => "Sair", -relief => "raised", -command => sub{exit 0} ); $Button3->place( -x => 270, -y => 14, -height => 25, -width => 64); $mw->geometry('350x50'); MainLoop; # Below is the sub that creates the doc sub geraNova { my $ctrl = './control.dat'; open(CTR, "+>>$ctrl") || die "Não foi posspivel abrir o arquivo. E +rro: $!"; flock(CTR, 2); my $id = <CTR>; flock(CTR, 8); close(CTR); $id = $id + 1; unlink $ctrl; open(CTR, "+>>$ctrl"); flock(CTR, 2); print CTR $id; flock(CTR, 8); close(CTR); $id = addZeros($id); #I've renamed the file after it was created and after this app was + closed my $file = 'C:\foo\path1\test'.$id.'.xls'; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Wi +n32::OLE->new('Excel.Application'); # I've tested with the alerts enabled and there was no error $Excel->{DisplayAlerts} = 0; $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Add(); $Book->SaveAs($file); my $ActBook = $Excel->Workbooks->Open("$file") || die "Não foi pos +sível abrir a planilha. Erro: $!"; undef $Excel; undef $Book; undef $ActBook; } sub addZeros { my $num = $_[0]; while(length($num) < 6) { $num = "0".$num; } return $num; } sub onAbout { my $about = $mw->DialogBox( -title=>"Sobre...", -buttons=>["OK"] ); $about->add('Label', -anchor => 'w', -justify => 'center', -text => qq( Excel Controller 1.0 by Er Galvão Abbott -Dúvidas, Bugs ou sugestões: galvao\@galvao.eti.br - Visite meu site em: http://www.galvao.eti.br/ ) )->pack; $about->Show(); }
my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");

In reply to Re: Re: Re: Re: Re: Re: Problems executing a copy command on win32 by DaWolf
in thread Problems executing a copy command on win32 by DaWolf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.