Re: unlink Footer/Header in VBA
- From: "Shauna Kelly" <ShaunaKelly@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 12 Jan 2008 11:44:42 +1100
Hi
Headers and footers are properties of a section. The section break at
the *end* of a section stores the properties of that section. So make
sure you can see the section breaks (see
http://www.word.mvps.org/FAQs/Formatting/NonPrintChars.htm).
(As an aside, all documents have at least one section. If a document has
only one section, you don't see a section break at the end of the
document. The final paragraph mark stores the relevant section
properties.)
Now, insert your text. Insert a section break after it. Click in the
text and format the section as you choose. Select both the text *and*
the section break and create an AutoText from that. When you insert that
AutoText it will bring the section break (and its properties) with it.
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
"Associates" <Associates@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F86D0339-4E7D-46DB-9E42-A6B302D81EDA@xxxxxxxxxxxxxxxx
Hi Shauna,
Thank you for your support. I'm really glad you offered another way of
getting around my problem.
I can create a very simple autotext like inserting "Bibliography" into
a
page. However, i was unable to create an autotext where it would have
a
Header, a footer and Bibliography all in one. So far, i could only
create
several autotexts, one for "Bibliography", another for "Header for
Bibliography" and another for "Footer for Bibliography". I wish i
could learn
to put these all into one autotext. So when user clicks on the button
"Insert
Bibliography" on the toolbar menu, it'd put in the header,
bibliography and
footer to the document.
I read the article you advised me to read about autotext. It said
items need
to be selected in the entry when creating autotext entry. I could only
select
the word "Bibliography", not the Header and the footer as they are
greyed
out. Hope you're still with me. Hence when creating the autotext
entry, i can
only see the word "Bibliography" without the header and the footer.
Also, i noticed that i'm still having problem with the numbering in
the
Footer. Even if the autotext can insert the Header, Bibliography and
Footer
(all in one page) into the document, i still have to manually unlink
it to
the previous and make it start from 1 as bibliography has a different
footer
formatting from the rest of the pages in the document.
sorry if i have made it so complicated for you to understand. Please
let me
know if have trouble understanding my problem.
Thank you in advance
For example:
I have a few pages at the start, their footer have the following
Page 1
Page 2
...
Page 7
---- section break ----
Page S1
Page S2
After deleting the section break, it stuffs up all the preceding
numbering
system in the footer as follows
Page S1
Page S2
...
Page S8
Page S9
I think i need some codes so that it would preserve whatever the
preceding
pages were as follow
Page 1
Page 2
...
Page 9
I guess, T
"Shauna Kelly" wrote:
Hi "Associates"
Thanks for the explanation. That helps a lot. Here is what I would
suggest:
1. Create a new .dot file. Do that by doing File > New and choosing
to
create a template. Use the user interface to create the styles and
page
format (eg paper size, margins) that you need in the template.
2. In the template, create an AutoText for each of the things that
you
want people to add to the document. From what you say, you'll need an
AutoText for:
- a table
- a bibliography
You probably don't want to include a section break after the table
AutoText, but you can include a section break after the Bibliography
AutoText. The section break will include the headers and footers you
need.
If you want to make an AutoText of a table, select the table using
Table
> Select > Table. Just make that the AutoText. Don't include any
extraneous paragraphs before or after it (unless, of course, you
suddenly decide you
More info at: Using AutoText
http://www.word.mvps.org/FAQs/Customization/AutoText.htm
3. Use Tools > Customize and make sure that the "Save in" box refers
to
your template.
On the Toolbars tab, create a new toolbar. Keep the Customize dialog
open.
On the Commands tab, in the Categories list, choose Insert. In the
Commands list find the button that says "From file" and has a picture
icon. Drag that to your menu. Right-click this new button on your
menu
and change the caption to whatever suits. This one button will now
invoke the Insert > Picture > From File command. You won't need to
write
any code to manage getting the image file and path name, coping if
the
user presses Esc half way through the process, detecting the kind of
image etc etc.
Back in the Customize dialog, on the Commands tab, in the Categories
list, click New Menu. In the Commands list, you'll see New Menu with
an
arrow. Drag that to your new toolbar. Right-click it and give it a
new
caption (eg "Insert...").
Now, back in the Customize dialog, on the Commands tab, in the
Categories list, click AutoText. In the Commands list you'll now see
the
AutoTexts you created. Drag each of them on to your new menu.
So, you now have a menu with a button that will allow people to
insert a
picture, and a menu that will allow people to insert the content you
stored in AutoTexts.
You probably don't need any of the code you currently have. You'll
need
to fiddle around with section breaks and the headers/footers but
depending on your needs, you might not need any code at all.
Hope this helps. Write back if you need more details.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
"Associates" <Associates@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6C3E1512-77CC-4BB7-B371-185B96B6E36C@xxxxxxxxxxxxxxxx
Hi Shauna,
Sorry for not providing you with sufficient info.
(a) What are you trying to achieve here?
The aim here is to set up a standard document template that would
enable our
staff to create a report for our company. At the moment, many
reports
are
different in terms of format. There are lots of inconsistencies
throughout
all the reports made by different staff. So we thought, by having a
proper
template made ready for staff to use, we could resolve this issue.
In the template (.dot), we plan on making lots of macros placed in
the
menu
that would enable user to do the job they desire. For example, we
have
macros
called "insert a section", "insert picture", "insert table", and
so
on. I
know these would override the features provided by word 03. But
these
macros
would shorten the steps needed for the staff to say "insert a
section
or sub
section" for example.
At the moment, i was creating a macro that would insert a
bibliography
into
the document. By clicking the button "insert bibliography", it
would
automatically create a new section break and put the word
"bibliography" as
the heading with appropriate header and footer. Of course, this
will
depend
on the location of the insertion point of the cursor as the
bibliography
section will be created in the next page.
So far, I'm struggling to make macro to insert the bibliography
section as
well as its footer and header to the document (the code for the
macro
was
posted earlier). Each of the sections (for example bibliography,
glossary,
etc) have their own different format of header and footer. So this
involves
lots of "unlink and link to the previous" as far as the
header/footer
is
concerned.
(c) Will users insert a bibliography into all different kinds ofMy idea was everytime someone wants to make up a document report
documents, or just some specific kinds of documents?
for
their
client. He/she can run this template and work on the report.
All the macros are available listed in the customised menu
specifically for
our own use.
Hopefully i explained it in words that can make things a lot
clearer
for you.
I'm happy and open to any other bright ideas you or anyone might
like
to
share. But this is the actual problem we're facing and trying to
resolve it.
And if we can pull this off - it would hopefully reduce time spent
on
checking for inconsistencies or errors found.
Thank you in advance
"Shauna Kelly" wrote:
Hi Associates
Can you back up here a few steps and tell us:
(a) What are you trying to achieve here? Explain it in words you'd
use
to your manager's manager.
(b) How does the user decide to insert the Bibliography? For
example,
do
you want the user to click on a button on a toolbar, or is this
code
part of something larger?
(c) Will users insert a bibliography into all different kinds of
documents, or just some specific kinds of documents?
(d) Where in the document is the bibliography inserted? For
example,
is
it always at the very end of the document?
Shauna
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
"Associates" <Associates@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:72F1BBAE-18C8-4CD1-81C6-7B077DCE0F79@xxxxxxxxxxxxxxxx
Hi,
I need your help desperately. I've been trying to get this to
work
since
yesterday but to no avail. I was trying to insert Header/Footer
using
VBA in
word 03. This will involve section breaks insertion into the
document.
My problem is i think i haven't really put the following code in
the
right
place.
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter.
_
LinkToPrevious
Different Sections will have different Header and Footer in the
document.
Here is my code of inserting a section of "Bibliography" into
the
document.
This might be placed in the middle of the document.
Sub InsertBibliography()
'Apply Header for previous section
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
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
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter.
_
LinkToPrevious
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Header 1"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=vbTab & vbTab & "Date Issue"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=16
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.InsertBreak Type:=wdSectionBreakNextPage
'Selection.InsertBreak Type:=wdPageBreak
Selection.TypeText Text:="Bibliography"
Selection.MoveLeft Unit:=wdCharacter, Count:=12,
Extend:=wdExtend
Selection.Font.Color = wdColorGreen
Selection.Font.Bold = wdToggle
Selection.Font.Size = 16
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
Selection.Font.Size = 12
Selection.Font.Color = wdColorAutomatic
'Apply Header for Bibliography
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
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
'Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
Selection.TypeText Text:="Company Name"
Selection.MoveLeft Unit:=wdCharacter, Count:=11,
Extend:=wdExtend
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="clientname"
.
- Follow-Ups:
- Re: unlink Footer/Header in VBA
- From: Associates
- Re: unlink Footer/Header in VBA
- References:
- unlink Footer/Header in VBA
- From: Associates
- Re: unlink Footer/Header in VBA
- From: Shauna Kelly
- Re: unlink Footer/Header in VBA
- From: Associates
- Re: unlink Footer/Header in VBA
- From: Shauna Kelly
- Re: unlink Footer/Header in VBA
- From: Associates
- unlink Footer/Header in VBA
- Prev by Date: Re: How word is started
- Next by Date: Re: MS Word Automation help
- Previous by thread: Re: unlink Footer/Header in VBA
- Next by thread: Re: unlink Footer/Header in VBA
- Index(es):
Loading