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

RE: inserting a file by bryan

bryan
Wed May 07 12:20:24 PDT 2008

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

"bryan" wrote:

> 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
>
>
>
>

RE: inserting a file by JeanGuyMarcil

JeanGuyMarcil
Wed May 07 12:35:22 PDT 2008

"bryan" wrote:

> 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...


RE: inserting a file by bryan

bryan
Wed May 07 13:24:01 PDT 2008

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

Bryan

"Jean-Guy Marcil" wrote:

> "bryan" wrote:
>
> > 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...
>