Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Macro to modify font in header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richardb - 20 Oct 2005 22:08 GMT
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...
Charles Kenyon - 20 Oct 2005 22:43 GMT
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.

Signature

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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

> My client is a medical office that uses a master document for each patient
> to
[quoted text clipped - 39 lines]
>
> Thank you...
richardb - 20 Oct 2005 23:33 GMT
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.

> 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
[quoted text clipped - 58 lines]
> >
> > Thank you...
richardb - 24 Oct 2005 15:22 GMT
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

> 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
[quoted text clipped - 58 lines]
> >
> > Thank you...
Charles Kenyon - 24 Oct 2005 16:22 GMT
You are welcome, glad I guessed right.
Signature

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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

> Dear Charles,
>
[quoted text clipped - 87 lines]
>> >
>> > Thank you...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.