Macro to modify font in header

R

richardb

My client is a medical office that uses a master document for each patient to
keep xray and MRI reports. They begin each new report with a macro that
inserts a section break to a new page and draws in a blank report with a
"letterhead" up in the document header. The Xray reports and the MRI reports
require different letter heads because they are generated by different
departments, so I added a user form so the operator can select which blank
document to insert for the next report. However, for one of inserted
documents there is a problem that the Tahoma font in the header changes to
Times Roman. I don't know how to fix that but thought I could add code to
find the text and change the font back to Tahoma. This works except that it
leaves the Times Roman formatted text up there alongside the new Tahoma
formatted text. Example "This is my textThis is my text"

My questions are: 1) Is there a better way to approach my problem; 2) what's
missing from my code (as shown):

'
' test12 Macro
' Macro recorded 10/20/2005 and modified by RichardB
'
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
With Selection
.Text = "This is the Header"
.Font.Name = "Tahoma"
.Font.Size = 14
.Font.Bold = wdToggle
End With
ActiveDocument.Save
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Thank you...
 
C

Charles Kenyon

Some thoughts from a tyro who's been doing word processing for about 20
years. First, look into styles and assigning styles rather than individual
direct formatting. http://addbalance.com/usersguide/styles.htm The way you
are doing it, you are reinventing the wheel. I would recommend two sets of
header and footer styles for your different sorts of reports. The second set
should be based on the first set because you want both to be based on either
the header or footer styles.

Second, use AutoText to hold your base formats rather than separate
documents.

Third, use the range object rather than the Selection object to apply your
formatting. http://word.mvps.org/FAQs/MacrosVBA.htm#Ranges

Fourth, "Master Document" is a term of art in Word referring to a "feature"
that not only doesn't work but also destroys documents. See
http://www.mvps.org/word/FAQs/General/WhyMasterDocsCorrupt.htm. I'm sure
this is not what you were talking about.

--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
R

richardb

Charles,

Thank you for your suggestions. Autotext sounds much better than what I'm
doing, but I have to try this. Each letterhead includes a different graphic
as a logo, plus lines and boxes. That will have to be stored in the autotext
and I have not tried such an autotext yet. I'll get back to you, probably
Monday.
 
R

richardb

Dear Charles,

I used your second suggestion to employ autotext and this worked fine. I
learned that autotext will hold all the graphics, lines, etc. of the header.
I used a macro to open the header and insert the autotext. Great!

I will make a point of learning more about the range object.

No I didn't mean Master Document as the Word Feature.

Many thanks for your help, which was "right on target" and instructive.

richardb
 
C

Charles Kenyon

You are welcome, glad I guessed right.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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

Similar Threads

Macro error 5941 1
Watermark macro 3
Bookmark problem 0
Macro to modify font of header 1
Macro to fix header 0
Update fields in footers 2
Out of Stack Space???? 2
Macro assitance for Letterhead 2

Top