control de Error 5152
Publicado por Jorge (1 intervención) el 28/07/2018 18:50:05
Estimados tengo un problema con esta macro al momento de insertar imagenes a traves de la función for. el problema consiste cuando ejecuta el control de errores. cuando sucede i=1 el control de errores se ejecuta normal, sin embargo cuando ejecuta el i=2 , sale el error 5152 la verdad no se porque sucede esto alguien me podría ayudar por favor
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
Sub insertar_picture()
'// Change to suit. Must have the trailing \
Const cStrDIR As String = "C:\TEMP\"
Dim rng As Range
Dim vShape As InlineShape
'// Remember where the cursor is...
Set rng = Selection.Range
'// Add the picture
For i = 65 To 67
On Error GoTo ErrHandler
Set vShape = Selection.InlineShapes.AddPicture(FileName:=cStrDIR & Chr(i) & ".jpg", LinkToFile:= _
False, SaveWithDocument:=True)
'// Resize. LockAspectRation maintains the aspect
'// This example makes it 1 inch high - you might prefer it smaller
With vShape
.Select
Selection.ShapeRange.WrapFormat.Type = wdWrapFront
.LockAspectRatio = True
.Height = InchesToPoints(1)
End With
ErrHandler:
If Err.Number = 5152 Then
MsgBox "The sig file '" & cStrDIR & Chr(i) & ".JPG' does not exist. Cannot add signature.", vbExclamation, "Not found"
End If
Next i
End Sub
Valora esta pregunta


0