Header/Footer view

T

TRM

Is there a way to set the view mode for the header/footer
of a template using VBA?

THANKS
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < TRM > écrivait :
In this message, < TRM > wrote:

|| Is there a way to set the view mode for the header/footer
|| of a template using VBA?
||
'_______________________________________
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
'_______________________________________

But why?

If you want to manipulate the header/footer content, it is better, if
possible, to use the range object, in which case you do not need to open the
view.

For example:

'_______________________________________
Dim HeaderRange As Range

With ActiveDocument
Set HeaderRange = .Sections(1) _
.Headers(wdHeaderFooterPrimary).Range
With HeaderRange
.Text = "This is the header."
.Font.Bold = True
End With
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

TRM

Well, actually, the information has already been entered
there, I just need to make sure the user can see it when
any document based off the template is opened. The
request has been made that the doc defaults to the view
being "on".

Merci & Bon soir! (It's been years! Please forgive me!)
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < TRM > écrivait :
In this message, < TRM > wrote:

| Well, actually, the information has already been entered
| there, I just need to make sure the user can see it when
| any document based off the template is opened. The
| request has been made that the doc defaults to the view
| being "on".
|

Ah! I get it now!
Then you need something else. As a user, I would not want to open a document
and have the header view activated automatically... Under those conditions,
as soon as I started typing, the header text would change. Unless this is
exactly what you want disregard what follows (I.e the first thing the user
needs to do is change the header as soon as the document is opened... But
even then, there are better ways to achieve this).

To make sure that the headers/footers are visible when opening a document,
makes sure the document opens with the print view:

ActiveWindow.View.Type = wdPrintView

Note that the content in headers/footers take on a greyish/pale look to
distinguish them from the body content (And, AFAICT, there is nothing you
can do about that.).
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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