Word - Macro Word Shapes.AddCanvas

 
Vista:
sin imagen de perfil

Macro Word Shapes.AddCanvas

Publicado por Rodolfo (2 intervenciones) el 18/01/2023 03:41:46
Buenas, tengo una duda con una macro, estoy insertando imagenes en todas las hojas de un documento, todo sin problema, el detalle es cuando la hoja tiene una tabla muy grande o al inicio del documento, los atributos left y top no me toman del documento si no de la tabla, como puedo hacer para que no haga eso??

la imagen que trato de adjuntar es la firma


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
For i = 1 To a
 
         If i = excep Then
            With Selection.Find
              .Forward = True
              .Wrap = wdFindStop
              .Text = "Marcelo Martinez"
              .Execute
            End With
            lefs = Selection.Information(wdHorizontalPositionRelativeToPage)
            tops = Selection.Information(wdVerticalPositionRelativeToPage)
 
            'Add a drawing canvas to the active document
           Set shpCanvas = ActiveDocument.Shapes _
           .AddCanvas(Left:=lefs - 40, Top:=tops + 20, _
           Width:=190, Height:=80)
 
           'Add a graphic to the drawing canvas
           shpCanvas.CanvasItems.AddPicture _
           FileName:="E:\firma marcelo vt.png", _
           LinkToFile:=False, SaveWithDocument:=True, Width:=190, Height:=80
        Else
            'Add a drawing canvas to the active document
           Set shpCanvas = ActiveDocument.Shapes _
           .AddCanvas(Left:=0, Top:=100, _
           Width:=80, Height:=190)
 
 
           'Add a graphic to the drawing canvas
           shpCanvas.CanvasItems.AddPicture _
           FileName:="E:\firma marcelo hz.png", _
           LinkToFile:=False, SaveWithDocument:=True, Width:=80, Height:=190
 
 
        End If
 
         With shpCanvas.PictureFormat
            .TransparentBackground = msoCTrue
           End With
tempsnip
tempsnip2
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
sin imagen de perfil

Macro Word Shapes.AddCanvas

Publicado por Rodolfo (2 intervenciones) el 18/01/2023 04:38:24
bueno lo pude resolver, al parecer cuando hace el cambio de hoja, entra en la tabla así que valide que la selección fuera una tabla y si lo era pasara a la siguiente linea y así hasta que el cursor este en una linea que no sea una tabla

1
2
3
4
5
xTable:
            If Selection.Information(wdWithInTable) Then
                Selection.GoToNext What:=wdGoToLine
                GoTo xTable
            End If

ese fue el codigo que agregue
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