Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2011, 05:14 PM
cksm4 cksm4 is offline Header/Footer lost with InsertFile Windows XP Header/Footer lost with InsertFile Office 2007
Advanced Beginner
Header/Footer lost with InsertFile
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default Header/Footer lost with InsertFile

Hello all,

Using the below code starting in a section where the Header/Footer is linked to the previous section is removing the link and causing the page numbering to delete. Is there a way to modify this code to link to Header and Footer to the previous section after each file is inserted? I cannot figure out how to get '.HeaderFooter.LinkToPrevious' to work. Any ideas?



Code:
 
ChDir ActiveDocument.Path
myName = Dir("03*.doc*")
While myName <> ""
    With Selection
        .InsertFile FileName:=myName, ConfirmConversions:=False
        .InsertBreak Type:=wdSectionBreakNextPage
        .Collapse Direction:=wdCollapseEnd
    End With
    myName = Dir()
Wend
Thanks!
Brock
Reply With Quote
  #2  
Old 03-04-2011, 08:44 PM
macropod's Avatar
macropod macropod is offline Header/Footer lost with InsertFile Windows 7 32bit Header/Footer lost with InsertFile Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Brock,

Using your code, I am only able to replicate the problem you describe if source document has its Section breaks. In such cases, you might choose to delete those Section breaks or change their formatting to 'same as previous'. As an example of the latter:
Code:
Sub Demo()
Dim myName As String, RngTmp As Range, Sctn As Section, HdFt As HeaderFooter
ChDir ActiveDocument.Path
myName = Dir("03*.doc*")
While myName <> ""
  With Selection
    Set RngTmp = .Range
    With RngTmp
      .Start = .Start - 1
      .End = .End + 1
    End With
    .InsertBreak Type:=wdSectionBreakNextPage
    .InsertFile FileName:="myName", ConfirmConversions:=False
    .InsertBreak Type:=wdSectionBreakNextPage
    With RngTmp
      For Each Sctn In .Sections
        With Sctn
          For Each HdFt In .Headers
            HdFt.LinkToPrevious = True
          Next HdFt
          For Each HdFt In .Footers
            HdFt.LinkToPrevious = True
          Next HdFt
        End With
      Next Sctn
    End With
  End With
  myName = Dir()
Wend
Set RngTmp = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-07-2011, 06:09 PM
cksm4 cksm4 is offline Header/Footer lost with InsertFile Windows XP Header/Footer lost with InsertFile Office 2007
Advanced Beginner
Header/Footer lost with InsertFile
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default

Hey Paul,

Yes, you were exactly right! The section break was hidden in a table. Much appreciated as I know this took extra time to diagnose. I also appreciate the code on linking the headers and footers... It works very well and accomplishes what I need. Thanks again!

Brock
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header/Footer lost with InsertFile Header & Footer Question - Help Need! Valentino.R Word 9 11-29-2010 08:23 AM
Different Header but same Footer Karthick Word 1 11-12-2010 09:08 AM
How do I remove header and footer captn1 Word 2 09-04-2010 04:14 PM
header/footer question Bobosmite Word 4 06-14-2010 07:22 AM
Header and footer questions boutells Word 0 07-21-2009 01:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft