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 / July 2005

Tip: Looking for answers? Try searching our database.

Inserting Logo in Header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anne P. - 19 Jul 2005 14:13 GMT
Hi all,

I am using the following code to insert a letterhead logo into a document:

 If chkLetterhead.Value = True And cmbOffices.Value = "NYLetterhead" Then
   If ActiveDocument.Bookmarks.Exists("Logo") Then
     Set mBmRange = ActiveDocument.Bookmarks("Logo").Range
     mBmRange = "NYLetterhead"
     mBmRange.InsertAutoText
     ActiveDocument.Bookmarks.Add Name:="Logo", Range:=mBmRange
   End If
 End If
 If chkLetterhead.Value = True And cmbOffices.Value = "DCLetterhead" Then
   If ActiveDocument.Bookmarks.Exists("Logo") Then
     Set mBmRange = ActiveDocument.Bookmarks("Logo").Range
     mBmRange = "DCLetterhead"
     mBmRange.InsertAutoText
     ActiveDocument.Bookmarks.Add Name:="Logo", Range:=mBmRange
   End If
 End If

If the bookmark named "Logo" is on the first page of the document this works
just fine.  However, if the bookmark is in the header, it freezes.  I am
using this same code in a different template to insert a logo and it works
just fine.  The only real difference between these two documents is that the
one that works is a Fax cover sheet which *DOES NOT* have Different First
Page turned on.  The other two templates that use it are a Memo and Letter
which both *DO* have Different First Page turned on.

Also, I have another question regarding headers and footers.  I read the
following article on the Word MVPS page about preventing users from editing
headers/footers in a document:
http://word.mvps.org/faqs/customization/ProtectWord2000PlusHeader.htm.
First, will the code from this article work in Word 2003?  And if it will,
can I change the line that reads:

      Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
              wdFirstPageFooterStory, wdFirstPageHeaderStory, _
              wdPrimaryFooterStory, wdPrimaryHeaderStory
       ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

so that only the First Page Header cannot be changed, or does it have to
protect all headers and footers?  The client wants to lock the header so
that when the document is e-mailed no one can delete the firm logo from the
header.

Thanks,

Anne P.
Charles Kenyon - 19 Jul 2005 14:54 GMT
There is no way for your client to email a Word document that someone else
can read and prevent them from saving something that looks like the original
without the header. Period. If, instead, it is converted to a non-editable
pdf file it can be a bit more difficult.

Why not use a template for your letterhead rather than a macro? You are
using a drill press when you need a screw driver. It is over-powered and not
quite the right tool, unless you have other reasons for using a macro that
are not apparent.

Take a look at: How to set up letterhead or some other document where you
want one header on the first page and a different header on other pages.
http://www.addbalance.com/word/headersfooters.htm This gives step-by-step
instructions. You can then lock the headers as shown in the article you've
read, keeping in mind my first statement.
Some other pages to look at:

Letterhead Tips and Instructions
http://home.earthlink.net/~wordfaqs/Letterhead.htm

Letterhead Textboxes and Styles tutorial
http://addbalance.com/word/download.htm#LetterheadTextboxesAndStylesTutorial

Template Basics
http://www.addbalance.com/usersguide/templates.htm

How to Create a Template - Part 2 - essential reading
http://www.mvps.org/word/FAQs/Customization/CreateATemplatePart2.htm

Word "Forms"
http://www.addbalance.com/word/wordwebresources.htm#Forms and

Word for Word Perfect Users
http://www.addbalance.com/word/wordperfect.htm if you are coming from a WP
environment (or even if you are not).

If you are interested in creating templates that will work with the letter
wizard or use that wizard, you should look at the chapter on Advanced
Document Formatting in Using Office 2003 (or whatever your version is),
Special Edition, by Ed Bott and Woody Leonhard. It has detailed instructions
including instructions on getting the fields you want from your Outlook
Contacts for addressing a letter. (Chapter 19 of SE Using Office 2003) You
should be able to get this through your public library or at Amazon.com
http://www.amazon.com/exec/obidos/ISBN=0789729555/balancecheckbookA/

Hope this helps,
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://www.mvps.org/word 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.

> Hi all,
>
[quoted text clipped - 45 lines]
>
> Anne P.
Anne P. - 19 Jul 2005 15:15 GMT
Charles,

Thanks for your answer.   However, I think you have misinterpreted something
from my post.  I *AM* using a template.  I have three templates, SK Fax, SK
Letter and SK Memo.  Each contains the code mentioned to insert a letterhead
logo, which has been saved as AutoText into the header.  The only one that
works is SK Fax and  I believe that one works because Different First Page
is not checked.  The other two templates have Different First Page checked
and the code is not working to insert the logo.  It freezes on the portion
that is inserting the logo.

I just found something and modified the code as follows:

 If chkLetterhead.Value = True And cmbOffices.Value = "NYLetterhead" Then
   ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
   If ActiveDocument.Bookmarks.Exists("Logo") Then
     Set mBmRange = ActiveDocument.Bookmarks("Logo").Range
     mBmRange = "NYLetterhead"
     mBmRange.InsertAutoText
     ActiveDocument.Bookmarks.Add Name:="Logo", Range:=mBmRange
     ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
   End If
 End If
 If chkLetterhead.Value = True And cmbOffices.Value = "DCLetterhead" Then
   ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
   If ActiveDocument.Bookmarks.Exists("Logo") Then
     Set mBmRange = ActiveDocument.Bookmarks("Logo").Range
     mBmRange = "DCLetterhead"
     mBmRange.InsertAutoText
     ActiveDocument.Bookmarks.Add Name:="Logo", Range:=mBmRange
     ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
   End If
 End If

This inserts the logo without freezing, however, the logo bookmark no longer
includes the logo.  I need it to be included in the logo bookmark so that
the user can later change from the NY to the DC letterhead.

In the meantime, I will look at some of the articles you pointed out for any
pointers.

Thanks,

Anne P.

> There is no way for your client to email a Word document that someone else
> can read and prevent them from saving something that looks like the
[quoted text clipped - 93 lines]
>>
>> Anne P.
Charles Kenyon - 19 Jul 2005 15:39 GMT
Try putting the AutoText into a separate global template. Have a different
global in each office. The AutoText should have the local address
information. The template always has the logo (which can also be an AutoText
entry). Then use AutoText fields in your header/footer to hold your
AutoText. You can have an AutoNew macro that updates the AutoText entries
and then unlinks the fields (changing the AutoText to plain text / graphics
without the fields). This way, the same template will work in both offices
and create different letterheads. I once did this to create letterhead and
forms for an office with 50 branches.

If you need to use a bookmark for insertion, take a look at
http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

The following macro updates REF fields in headers/footers (and in the body).
You could substitute AutoText fields instead and both update and then
unlink.

Sub RefFieldUpdateAllStory()
'   Written by Charles Kyle Kenyon 15 November 2001
'   repaired by Jezebel
'   All Story Field Updater - Ref fields
   Dim oField As Field
   Dim oStory As Range
'    On Error Resume Next
   For Each oStory In ActiveDocument.StoryRanges
   ' This goes into headers and footers as well as the regular document
       Do
           For Each oField In oStory.Fields
               If oField.Type = wdFieldRef Then
                   oField.Update
               End If
           Next oField
           Set oStory = oStory.Next
       Loop Until oStory Is Nothing
   Next oStory
End Sub

Charles Kenyon

Signature

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


Signature

See also the MVP FAQ: http://www.mvps.org/word 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.


> Charles,
>
[quoted text clipped - 141 lines]
>>>
>>> Anne P.
Dan Bridgland - 26 Jul 2005 10:39 GMT
I too am looking for a way to restrict the header and footer but only
on the first page. this is to stop users amending the text.  Can this
code be amended to work only for the first page?

Thanks
Dan
 
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.