in reply to Re: add image in a specific cell
in thread add image in a specific cell

Hi !!! I am using WIN32::OLE only, can I combine both modules?

Replies are listed 'Best First'.
Re^3: add image in a specific cell
by olus (Curate) on Feb 29, 2008 at 17:52 UTC

    I tried your code and it worked. Just to make sure, have you called Activate on your $Hoja? Like:

    $Hoja = $workbook->>Worksheets(1); $Hoja->Activate();
      Hi thank you for helping me but I got confuse these is the part of the code is ok where I put the $Hoja->Activate();
      #!/usr/perl/bin use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; my $filename = $ARGV[0]; my $filename2 = $ARGV[1]; ################################################################# # Nota : # para el programa semarnat este es el formato: # SEMARNAT NUMEROFOLIO.XLS FORMATONUMEROFOLIO.XLS # # para el programa que genera el codigo de barras pdf417: # Pdf417lib NUMEROFOLIO.ASC FORMATONUMEROFOLIO.JPG # ################################################################# system ("copy datafill.xls $filename2.xls"); my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); #------ Abro el archivo CSV y lo dirijo al primera hoja de trabajo + ----- my $Book = $Excel->Workbooks->Open("C:\\projectword\\$filename.xls +"); my $Sheet = $Book->Worksheets(1); #----- View file ----------------------- my $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Q +uit'); #Generacion del codigo para agregar my $Libro = $excel->Workbooks->Open("c:\\Projectword\\$filename2.x +ls"); my $Hoja = $Libro->Worksheets(1); # $Hoja = $workbook->>Worksheets(1); #my $UltimaRegla = $Hoja->UsedRange->Find({What=>"*", # SearchDirection=>xlPrevious, # SearchOrder=>xlByRows})->{Row}; # #my $Renglon = $UltimaRegla + 25; $Sheet->Range("A1")->Copy(); $Sheet->Paste ({Destination => $Hoja->Range("H9")}); $Hoja -> Range("H9") -> Font -> {Size}=7; $Sheet->Range("B1")->Copy(); $Hoja -> Range("B61") -> Borders(xlEdgeLeft) -> {LineStyle} = + xlContinuous; $Hoja -> Range("B61") -> Borders(xlEdgeLeft) -> {Weight} = + xlThin; $Hoja -> Range("B61") -> Borders(xlEdgeBottom) -> {LineStyle} + = xlContinuous; $Hoja -> Range("B61") -> Borders(xlEdgeBottom) -> {Weight} + = xlThin; ###################################################################### +############################ system ("java -classpath . Pdf417lib $filename.asc $filename2.jpg 0.3" +); $Hoja->Activate(); $Hoja -> Range("E47")->Select(); $Excel->ActiveSheet->Pictures->Insert('c:\projectword\$filename2.jpg') +; $excel -> {DisplayAlerts} = 0; $excel->{Visible}= 1; # $Hoja->PrintOut(); # $Hoja->PrintOut(); $excel->close();
      I try it like this put the barcode is still being place on top I am doing something wrong???

        This will not work. $filename2 will not be interpolated. You should be using double-quotes (").

        $Excel->ActiveSheet->Pictures->Insert('c:\projectword\$filename2.jpg');

        Careful on the names you assign to variables. You have $excel and $Excel. $Libro and $Hoja are from $excel. You are selecting a range on $excel, but adding the picture on $Excel.

        You are not saving the changes to your $Libro.

        # tendras que anadir $Libro->SaveAs("----");