Buenos dias colegas, esta vez requiero de su valiosa ayuda para saber, como se manipulan comando del editor de visual Basic en Excel.
sto es porque genero un reporte en excel y a ese reporte anexarle imagenes de acuerdo con los registros, todo en excel. Pero para insertar las imagenes se necesita que el excel contenga una macro para ello. Entonces ahi entran los comandos de VBA, cmo los manipulo desde Xojo para crear una macro al crear la hoja de excel???
o alguien tiene alguna otra idea de como hacer esto… bienvenido sea…
Gracias por su ayuda…
Hola, estoy utilizando el traductor de google, y por favor, disculpe cualquier error.
Aqu est el cdigo Xojo que se abre un documento de Excel, selecciona la imagen, copia la fotografa de la memoria del ordenador, selecciona una nueva hoja y pegar la nueva imagen.
[code] Dim Excel as new ExcelApplication
Excel.Visible = true
'Open Excel Workbook
Excel.Workbooks.Open(“C:\test\Dolomite.xlsx”)
'Select the picture in the Workbook
Excel.ActiveSheet.Shapes.Range(“Picture 1”).select_
'Copy the picture to memory
Excel.Selection.CopyPicture
'Select Sheet 2 and paste the picture
Excel.Sheets(“Sheet2”).Select_
Excel.ActiveSheet.Paste
'Create a PDF file from the picture in Sheet 2
Excel.ActiveSheet.ExportAsFixedFormat(0, “C:\test\Dolomite.pdf”, 0, true, False, True)
'Excel.ActiveSheet.ExportAsFixedFormat(Office.xlTypePDF, “C:\test\Dolomite.pdf”, Office.xlQualityStandard, true, False, True)
exception err
MsgBox err.message
[/code]
Feliz de ayudar.
Thank you Eugene’s help, I will put it into practice and comment on results.
//////////////////////////////////////////////////////////////////////////////////////////
Muchas Gracias Por la ayuda Eugene, lo pondr en practica y comentar resultados.
I analyzed the code, and good, everything works, what I want is that the image you select a folder and paste it in excel, according to criteria …
For example:
I have 3 fields:
ID NAME IMAGE
1 JHON JHON PHOTO
the image information associated with the previous cell …
Sorry if I did not explain me
Hello Santiago,
Here is a screen grab of the results:

Download the Code
Is this correct?
this perfect … now that I wanted to adapt my Code, but mark me the following error…

Error OLEException
Mesagge: Exception code 0: Unable to get the Insert property of the Pictures class (failed on “Insert”)
Something I’m doing wrong and not know what is
Hello Santiago,
Maybe an error with the file location. Use the full folder path and file name.
Try this:
ImgFile = GetFolderitem("C:\\windows\\temp\\Xojo\\Tecnologia.jpg")
Happy to help.
Thanks Eugene, was a great help, only I modified your code a bit and I adapted to my project and it really works …
I have another question for you, as I do to save multiple images at once on my PC from the database, I have images stored in blob fields, how download?
Hi Santiago,
Which database are you using? (Possibly Microsoft Access, or SQLite?)
Could you give me some example code?
A very good question!
I am using MySQL
and the code is as follows …
[code] Dim i, Filas As Integer
Filas = ListaDetalles.ListCount
For i = 0 to Filas
Dim GIMA As RecordSet
Dim ImagenCarp As FolderItem
Dim Foto As Picture
ImagenCarp = SpecialFolder.Windows.Child("/Temp/")
GIMA = Android.SQLSelect("SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia='" + Trim(PopPlanta.Text) + "'AND HoraEvi='" + Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 0)) + "'")
Foto=GIMA.Field("FotoEvidencia").PictureValue
Foto.Save(ImagenCarp.Child("/TempXojo/" +Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 1)) +".jpg"), Picture.SaveAsJPEG)
Next[/code]
When the Change is True PopupMenu, event logs compare a column with the column of the database and store the appropriate image in a folder.
The code only works for the first. only save an image, being that there are more records.
Something is escaping me and what is not?
ListaDetalles = ListBox
Android = MySQL DataBase
Te respondo lo que amablemente Dave te contesto en el foro de Database.
Sustituye LastIndex por i o sino estars escribiendo siempre el mismo valor (el ltimo, que es que indica lastindex).
Este tipo de problemas lo puedes solucionar muy fcilmente utilizando el debugger de Xojo. Pon un breakpoint dentro de la funcin que te de problemas, y vas avanzado y comparando los valores que te da el debugger. Lo primero que recomiendo a cualquiera que quiera iniciarse en Xojo es primero aprender a manejar el debugger y luego nociones bsicas de programacin orientada al objeto, sobre todo si vienes de Visual Basic 6.
Espero haberte ayudado. Utilizo solo Mac y no puedo testar el cdigo de Excel por el que preguntas.
Hello Santiago,
You are correct with the for-next loop.
Please add:
gima.movenext
(movenext = proximopaso) ?
This will advance the next recordset record.
[code] Dim i, Filas As Integer
Filas = ListaDetalles.ListCount
For i = 0 to Filas
Dim GIMA As RecordSet
Dim ImagenCarp As FolderItem
Dim Foto As Picture
ImagenCarp = SpecialFolder.Windows.Child("/Temp/")
GIMA = Android.SQLSelect("SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia='" + Trim(PopPlanta.Text) + "'AND HoraEvi='" + Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 0)) + "'")
Foto=GIMA.Field("FotoEvidencia").PictureValue
Foto.Save(ImagenCarp.Child("/TempXojo/" +Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 1)) +".jpg"), Picture.SaveAsJPEG)
gima.MoveNext
Next i[/code]
Does this work for you?
Feliz de ayudar 
Gracias a tu ayuda y a otros miembros del foro(dave y Amando), he resuelto mi problemita, si s manejar lo bsico en Xojo Amando, slo que se me olvidan uno que otro gran detalle… muchas gracias a todos…
Espero no volver a molestarlos.
[quote=68134:@Santiago Hernandez]
Espero no volver a molestarlos.[/quote]
Molestia ninguna! Aquí estamos para ayudarnos los unos a los otros, es lo que hace a la comunidad de Xojo tan especial.
Gracias Amando, un gran saludo…