Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello.
    I'm trying to create a macro that
    inserts next page section break
    navigates to section two header
    disables 'link to previous'
    deletes the (previous) image from section two header, then
    creates a new header from section two.
    However, when the picture is deleted Word switches to the header for section one.

    How can I correctly navigate between the two section headers?
    Thanks, Andy.

  2. #2
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts
    .. should have mentioned this is for Word 2003,
    and that the final result is that the headers for section 1 and 2 are in the wrong order.
    Andy.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try code like this:

    Code:
    Dim lngSection As Long
    lngSection = Selection.Information(Type:=wdActiveEndSectionNumber)
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    With ActiveDocument.Sections(lngSection + 1).Headers(wdHeaderFooterPrimary)
      .LinkToPrevious = False
      .Shapes(lngSection + 1).Delete
      .Range.Text = "My new header text"
    End With
    Note: working with shapes in headers and footers is very tricky because all shapes in all headers and footers form a single collection.

  4. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='794239' date='21-Sep-2009 10:57']Try code like this:

    Code:
    Dim lngSection As Long
    lngSection = Selection.Information(Type:=wdActiveEndSectionNumber)
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    With ActiveDocument.Sections(lngSection + 1).Headers(wdHeaderFooterPrimary)
      .LinkToPrevious = False
      .Shapes(lngSection + 1).Delete
      .Range.Text = "My new header text"
    End With
    Note: working with shapes in headers and footers is very tricky because all shapes in all headers and footers form a single collection.[/quote]
    Thank you very much. I shall explore this. Andy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •