T
Tony Logan
I'm using a macro to append a number of files to an initial file. A problem
occurs when the first page of the initial file has content in the headers and
footers (in this case, various horizontal rules...set as page borders,
actually). When appending files, these rules appear in all subsequent files.
I tried recording a macro to solve the problem, but when I run the macro,
the cursor jumps out of the second header and moves to the first header when
the code reaches this line:
With Selection.ParagraphFormat
I've tried various things, but each time I get to the above line, the cursor
jumps to the first header. Here's the chunk of code in question:
' make sure we're in Print View
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
' unlink header on page 2 from header on page 1
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
With Selection.ParagraphFormat ' here's where the problem occurs
' delete the various page borders from the header
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
End With
Not sure if I need to rewrite the code entirely or just find a substitute
bit of code for the "With Selection.ParagraphFormat" line.
occurs when the first page of the initial file has content in the headers and
footers (in this case, various horizontal rules...set as page borders,
actually). When appending files, these rules appear in all subsequent files.
I tried recording a macro to solve the problem, but when I run the macro,
the cursor jumps out of the second header and moves to the first header when
the code reaches this line:
With Selection.ParagraphFormat
I've tried various things, but each time I get to the above line, the cursor
jumps to the first header. Here's the chunk of code in question:
' make sure we're in Print View
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
' unlink header on page 2 from header on page 1
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
With Selection.ParagraphFormat ' here's where the problem occurs
' delete the various page borders from the header
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
End With
Not sure if I need to rewrite the code entirely or just find a substitute
bit of code for the "With Selection.ParagraphFormat" line.