Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: import a header

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

import a header
"Antonhino" <antoine.andre[ at ]gmail.com> 20.02.2006 09:34:49
Good morning
I would like to import a header to a word document from the macro of
another word document.
Thank you.

Re: import a header
"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> 20.02.2006 12:37:14
I am not really sure what you want to do, but the following will create a
new document and insert into it the header of the activedocument.

Dim source As Document, target As Document, hrange As Range
Set source = ActiveDocument
Set target = Documents.Add
Set hrange = source.Sections(1).Headers(wdHeaderFooterPrimary).Range
hrange.End = hrange.End - 1
target.Sections(1).Headers(wdHeaderFooterPrimary).Range = hrange


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Antonhino" <antoine.andre[ at ]gmail.com> wrote in message
news:1140428089.208740.158980[ at ]g44g2000cwa.googlegroups.com...
[Quoted Text]
> Good morning
> I would like to import a header to a word document from the macro of
> another word document.
> Thank you.
>


Re: import a header
"Antonhino" <antoine.andre[ at ]gmail.com> 20.02.2006 13:43:35
Thanks for your answer,
but in fact, I want to insert the header of an existing document into
the active document.

Antonhino

Re: import a header
"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> 20.02.2006 16:42:10
In that case you would use:

Dim source As Document, target As Document, hrange As Range
Set target = ActiveDocument
Set source = Documents.Open("path\filename")
Set hrange = source.Sections(1).Headers(wdHeaderFooterPrimary).Range
hrange.End = hrange.End - 1
target.Sections(1).Headers(wdHeaderFooterPrimary).Range = hrange


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Antonhino" <antoine.andre[ at ]gmail.com> wrote in message
news:1140443015.799379.95500[ at ]g14g2000cwa.googlegroups.com...
[Quoted Text]
> Thanks for your answer,
> but in fact, I want to insert the header of an existing document into
> the active document.
>
> Antonhino
>


Re: import a header
"Antonhino" <antoine.andre[ at ]gmail.com> 20.02.2006 17:08:50
Thank you it works.
regards,

Antonhino

Re: import a header
"Antonhino" <antoine.andre[ at ]gmail.com> 20.02.2006 17:38:55
In fact it works well for the text, but it doesn't import pictures.
What should I do.
Thanks.

Re: import a header
"Doug Robbins - Word MVP" <dkr[ at ]REMOVETHISmvps.org> 20.02.2006 18:08:12
It may be easier to consider another approach. Open the document with the
required Header, replace all the text in it with the text in the document in
which you want the header and save it with a new name.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Antonhino" <antoine.andre[ at ]gmail.com> wrote in message
news:1140457135.510645.266040[ at ]f14g2000cwb.googlegroups.com...
[Quoted Text]
> In fact it works well for the text, but it doesn't import pictures.
> What should I do.
> Thanks.
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net