Visual Basic - Correccion codigo Importar Foto

Life is soft - evento anual de software empresarial
 
Vista:

Correccion codigo Importar Foto

Publicado por Ignacio (16 intervenciones) el 10/01/2013 09:55:02
Buenas, estoy intentando importar una foto con VB, tengo este codigo pero no me funciona y no se por que, cuando lo aplico se colapsa excel. Seria de gran ayuda si alguien me lo podria corregir... Muchas gracias


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Sub ImportPicture()
Dim row As Long
Dim i As Long
Dim Blatt As Long
Dim picPath As String
Dim Picture As Object
Dim dHeight As Double
Dim dWidth As Double
Dim mylmg As Object
 
 
Blatt = 12
 
Blatt = Blatt * 19 + 32
 
row 52
On Error Resume Next
While Cells(row, 7) <> ""
picPath = "K:\11PCB\99FAROLEAN\C_Dokumente und Vorlagen\Logo\FAROLEAN_LOGO.jpg" + Cells(row, 7) + "jpg"
 
Sheets(Hoja2).Select
i = 32
On Error Resume Next
 
While i <> Blatt
 
Cells(12, i).Select
Set mylmg = ActiveSheets.Pictures.Insert(picPath)
 
With mylmg
dWidth = .Width
dHeight = .Height
.Width = 300
.Height = 200
 
End With
 
mylmg.Top = ActiveCell.Top
mylmg.Left = ActiveCell.Left
Rows(row).RowHeight = mylmg.Height
 
i = i + 19
Wend
 
 
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Correccion codigo Importar Foto

Publicado por Juan José Jimenez (8 intervenciones) el 21/01/2013 05:31:38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Sub ImportPicture()
Dim ro As Long
Dim i As Long
Dim Blatt As Long
Dim picPath As String
Dim Picture As Object
Dim dHeight As Double
Dim dWidth As Double
Dim mylmg As Object
 
Blatt = 12
 
 
Blatt = Blatt * 19 + 32
 
'asumo que en las celdas de la columna 7 de la hoja1 estan el nombre de las imagenes que deseas cargar
'no se si row es palabra reservada asi que coloque ro
ro = 52
On Error Resume Next
While Cells(ro, 7) <> ""
picPath = "K:\11PCB\99FAROLEAN\C_Dokumente und Vorlagen\Logo\" + Cells(row, 7) + ".jpg"
 
Sheets(Hoja2).Select
i = 32
On Error Resume Next
 
' no se si el valor de blat es mutiplo de 19 por lo que coloque < en lugar de <>
While i < Blatt
 
Cells(12, i).Select
Set mylmg = ActiveSheets.Pictures.Insert(picPath)
 
With mylmg
dWidth = .Width
dHeight = .Height
.Width = 300
.Height = 200
 
End With
 
mylmg.Top = ActiveCell.Top
mylmg.Left = ActiveCell.Left
Rows(ro).RowHeight = mylmg.Height
 
i = i + 19
Wend
' si no increentas la varioable ro queda en loop infinito
 
ro = ro + 1
wend
 
 
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar