Insertar imágen de recurso en Excel

Insertar imágen de recurso en Excel

Postby acuellar » Thu Mar 09, 2023 8:32 pm

Estimados,

Se puede?

Code: Select all  Expand view

 oSheet:Pictures:Insert("RECURSO") //Sólo permite con imágenes en disco
 
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1643
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Insertar imágen de recurso en Excel

Postby karinha » Fri Mar 10, 2023 2:58 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7823
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Insertar imágen de recurso en Excel

Postby acuellar » Fri Mar 10, 2023 5:09 pm

Gracias estimado Joao

Lo he logrado así.
Code: Select all  Expand view

    FW_SaveImage( "LOGO", ViaFiles+"logo.png" )
    cLogo:=ViaFiles+"Logo.png"
    oSheet:Range( "R1:R1" ):Select()
    oSheet:Pictures:Insert(cLogo)
 


Claro que quisiera que fuera directamente :(
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1643
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Insertar imágen de recurso en Excel

Postby Jimmy » Mon Mar 13, 2023 7:08 am

hi

i have ask ChatGPT

how can i insert a Bitmap into Excel sheet via activex ?
You can insert a Bitmap into an Excel sheet via ActiveX by using the InsertPicture method of the Range object.

This method takes two parameters: the path to the Bitmap file and an optional parameter for the PictureType.
For example:
Range("A1").InsertPicture "C:\MyBitmap.bmp", xlBitmap

---

how can i insert a Bitmap into a Cell of a Excel sheet via activex ?
You can insert a Bitmap into a Cell of an Excel sheet via ActiveX by using the InsertPicture method of the Range object. The syntax for this method is:

Range.InsertPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height, Anchor).

The Filename parameter is the path to the Bitmap file you want to insert.
The LinkToFile parameter is a Boolean value that determines whether the Bitmap is linked to the file or not.
The SaveWithDocument parameter is a Boolean value that determines whether the Bitmap is saved with the document or not.
The Left, Top, Width, and Height parameters are the coordinates and size of the Bitmap.
The Anchor parameter is an object that determines where the Bitmap is anchored in the cell.

please try it and lt use know if it work
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Insertar imágen de recurso en Excel

Postby acuellar » Mon Mar 13, 2023 8:18 pm

Jimmy

It doesn't work :(
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1643
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Insertar imágen de recurso en Excel

Postby Jimmy » Tue Mar 14, 2023 1:46 am

hi,

ChatGPT will (most) not give you running CODE ... it give you Idea and a new Direction

i have never try to put a Bitmap into a Excel Sheet but "Insert" seems me not the Way
after ChatGPT give me a Answer i have search for "InsertPicture" and it does exist

Graphic Object (Excel)

Contains properties that apply to header and footer picture objects.

Collapse sectionRemarks
There are several properties of the PageSetup object that return the Graphic object.

Use the CenterFooterPicture , CenterHeaderPicture , LeftFooterPicture , LeftHeaderPicture , RightFooterPicture , or RightHeaderPicture properties to return a Graphic object.

NoteNote
It is required that "&G" is a part of the LeftFooter string in order for the image to show up in the left footer.

Collapse sectionExample
The following example adds a picture titled: Sample.jpg from the C:\ drive to the left section of the footer. This example assumes that a file called Sample.jpg exists on the C:\ drive.
Code: Select all  Expand view
VBA  Copy codeCopy code
Sub InsertPicture()
 
 With ActiveSheet.PageSetup.LeftFooterPicture
 .FileName = "C:\Sample.jpg"
 .Height = 275.25
 .Width = 463.5
 .Brightness = 0.36
 .ColorType = msoPictureGrayscale
 .Contrast = 0.39
 .CropBottom = -14.4
 .CropLeft = -28.8
 .CropRight = -14.4
 .CropTop = 21.6
 End With
 
 ' Enable the image to show up in the left footer.
 ActiveSheet.PageSetup.LeftFooter = "&G"
 
End Sub


but it seems to have limitation to "Header" and "Footer"
so i´m not sure if it is the right Way for you
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Insertar imágen de recurso en Excel

Postby jbrita » Tue Mar 14, 2023 11:50 am

yo lo hago asi

LOCAL cLogo:="c:\systema\bus\ima\logo.bmp"
oSheet:Shapes:AddPicture( cLogo, .F., .T., 0, 0, 130, 50 )

saludos
jbrita
 
Posts: 502
Joined: Mon Jan 16, 2006 3:42 pm

Re: Insertar imágen de recurso en Excel

Postby acuellar » Tue Mar 14, 2023 12:42 pm

Gracias estimado jbrita

Es lo mismo

La idea es insertar la imagen directamente desde el recurso.
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1643
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests