inserting a file

B

bryan

I am using the following code to insert a file into a template which has
letterhead and footer.
"
Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:MN Collective Bargaining Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With

The template has letterhead, so this code adds a section break with the
letterhead and footer (Company address, emial, etc).
What I want to do is just add a word file next page as it is (no letterhead
or footer).
I have tried different things , even manually, like insert > Break > Page
break and I don't get the header but, still get the footer.

Any thoughts..
Thanks,
Bryan
 
B

bryan

Addendum:
When I do this manually and insert break > page break, the footer appears
but, I cna double click it and then it goes away and any subsequent does not
have it either.
With this info then, and if unable to insert without the footer, when I
insert a break is there a way to programmically delete the footer?

Thanks,
Bryan
 
J

Jean-Guy Marcil

bryan said:
I am using the following code to insert a file into a template which has
letterhead and footer.
"
Dim myDoc As Document
Dim docrange As Range

Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:MN Collective Bargaining Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With

The template has letterhead, so this code adds a section break with the
letterhead and footer (Company address, emial, etc).
What I want to do is just add a word file next page as it is (no letterhead
or footer).
I have tried different things , even manually, like insert > Break > Page
break and I don't get the header but, still get the footer.

I am not sure I understand your problem...
I think that all you want to do is add a file at the end of the document,
but not have any header/footer starting from page 2, then the solution is
real easy...

Just set your basic doument (the letterhead one) to have a first page
header/footer different from other pages. In the first page header/footer
type/insert your letterhead stuff and make sure that the second page
header/footer are empty. You may need to insert a temporary page break to
access this second page header/footer. You can remove the page brreak once
you are done, Word will "remember" your settings even if there is no second
page. (It would be the same if you wanted a one page template with special
odd/even page header/footer content, in that case you would need to insert
two temporary page breaks...)

Finally, in your code, insert a page break instead of a section break.
(Or a paragraph with the setting "Page Break Before.")


If you must use a section break, then in your code after inserting the
section break, access the header/footer for section 2 (the new section) with
"ActiveDocument.Sections(2).Header(wdHeaderFooterPrimary).Range". Unlink them
from the previous header/footer and delete the content...
 
B

bryan

Thanks,
that was the problem with the letterhead. Once that was solved I can now
just do PageBreak.

Bryan
 

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