met macro afbeelding selecteren in koptekst van WORD 2010

Status
Niet open voor verdere reacties.

Anton2008

Gebruiker
Lid geworden
1 jul 2008
Berichten
11
Ik probeer een macro (of VBA) te maken waarbij ik een afbeelding die in de koptekst aanwezig is (plaatsen lukt nog wel) te wijzigen, in grootte en locatie.

enig idee ?
Kan ik een afbeelding zelf een naam geven bij het inlezen, en dan wijzigen ? Dat zou handig zijn als er meerdere afbeeldingen in de koptekst staan (verwijzen naar "picture 1" werkt namelijk niet zo handig)
 
Een klein voorbeeldje, waarmee je vormen kunt manipuleren in een koptekst.

Code:
Sub TestVormen()

Dim iSectionCount As Integer
Dim NextSectCount As Integer
Dim i As Integer
Dim SectShapes As Integer
Dim shp As Shape
Dim NewName As String
iSectionCount = ActiveDocument.Sections.Count

For i = 1 To iSectionCount
    Selection.GoTo wdGoToSection, Which:=(i)
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    'Count the shapes in the headers of the current section
    SectShapes = ActiveDocument.Sections(i).Headers(wdHeaderFooterFirstPage).Shapes.Count
    If SectShapes > 0 Then
        For Each shp In ActiveDocument.Sections(i).Headers(wdHeaderFooterFirstPage).Shapes
            NewName = InputBox("Typ de nieuwe naam voor het object", "NieuweNaam", shp.Name)
            With shp
                .Name = NewName
                .Height = 36
            End With
            If shp.Name Like "PowerPlusWatermarkDraft*" Then
                shp.Height = 36
                shp.Delete
            End If
        Next shp
    End If
    'Go to next header. If same section, must have "first page headers different" (or "Odd" and "Even" page headers)
    'Could therefore have 2 headers in only 1 section (like letters)
    'ActiveWindow.ActivePane.View.NextHeaderFooter
    NextSectCount = Selection.Information(wdActiveEndSectionNumber)
    If NextSectCount = i Then
        SectShapes = ActiveDocument.Sections(i).Headers(wdHeaderFooterFirstPage).Shapes.Count
        MsgBox "Section " & i & " contains " & SectShapes & " Shapes"
        'reset nextSectCount for the next check it makes
        NextSectCount = 0
    End If
Next i

End Sub
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan