Footers

F

Fuzzhead

We are converting all of our procedures from WordPerfect to Word and the
conversion leaves some cleanup work. I have macros that clean up everything
but 2 items. The first is to delete the old footers and the second is to
replace the first page of the converted procedure with the first page of our
new Master Template which is on my C Drive. Is there a way to do this?
 
B

Bear

Fuzzhead:

This should get you started. I've just saved the first page as a separate
document named trash.doc.

Sub YourNameHere()

Dim objSection As Section
Dim objRange As Range
Dim objHeaderFooter As HeaderFooter

' Delete all footers from each section

For Each objSection In ActiveDocument.Sections
For Each objHeaderFooter In objSection.Footers
objHeaderFooter.Range.Delete
Next objHeaderFooter
Next objSection

' Create a range for the start of the document

Set objRange = ActiveDocument.Range
objRange.End = objRange.Start

' Insert the first page file

objRange.InsertFile _
FileName:="trash.doc", _
Range:="", _
ConfirmConversions:=False, _
Link:=False, _
Attachment:=False

' Destroy the objects

Set objSection = Nothing
Set objRange = Nothing
Set objHeaderFooter = Nothing

End Sub

Bear
 
F

Fuzzhead

Hi Bear,

The first part of your macro worked. It removed all of the footers from the
old document. The second part inserted the whole Master template at the
beginning of the new document and did not delete the old first page.

Fuzzhead
 
B

Bear

Fuzzhead:

The macro worked as intended. I tried to explain my assumptions: I did not
store the "new" page 1 in the template. I stored it in a separate document. I
intended for that entire document to be inserted at the front of the target
document, without replacing anything.

Replacing a page is difficult and not always accurate. It would be simpler
if a section could be replaced.

Can you do that?

Bear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top