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

Tip: Looking for answers? Try searching our database.

Textbox in Header problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent B. - 01 Apr 2005 23:59 GMT
I have a letterhead template that has a text box inserted and locked in
position outside of the bounding area of the header area that holds the
company logo. When I copy the original documents primary header and paste it
into the new letterhead document, the textbox logo is gone. This is how I'm
trying it.

Original document is active -
activedocument.StoryRanges(wdPrimaryHeaderStory).Copy

I make the new document active -
activedocument.StoryRanges(wdPrimaryHeaderStory).Paste

The text contained in the original document shows up in the new document's
header but the textbox logo is gone.

Any thoughts?

Thanks,
Brent
Charles Kenyon - 03 Apr 2005 07:40 GMT
Are you sure that your textbox is anchored in the header rather than on page
1 of the body of your document? Does it show up as faded when you are not
viewing the header/footer? I routinely copy a header that includes a textbox
using code, but the textbox is anchored inside a bookmark and it is the
bookmark contents that are copied. The following is my code, hope it helps.

Private Sub ReplaceHeaders(sTemplateName As String)
   '   Altered to delete ranges 28 March 2004
   '
   '   Replaces Header and FirstPageHeader with contents from
   '       base template
   '   Replaces Footer and FirstPageFooter with contents from
   '       base template
   '   Assumes that bookmarks have been preserved in base and copies.
   '   Otherwise will generate error
   '   Required bookmarks are "Footer1," "Footer2," "Header1," and
"Header2"
   '
   Dim rRange As Range
   Dim sFooter As String
   Dim sHeader As String
   Dim iCount As Integer
   '
'    For iCount = 1 To 1 '   Replace 1st page header/footer only
   For iCount = 1 To 2 '   Replace both headers, letterhead & continuation
       sFooter = "Footer" & iCount
       sHeader = "Header" & iCount
       Set rRange = ActiveDocument.Bookmarks(sHeader).Range
       rRange.Delete
       rRange.InsertFile FileName:=WorkGroupPath _
           & "Letters & Faxes\" & sTemplateName, _
           Range:=sHeader, _
           ConfirmConversions:=False, Attachment:=False, Link:=False
       Set rRange = ActiveDocument.Bookmarks(sFooter).Range
       rRange.Delete
       rRange.InsertFile FileName:=WorkGroupPath _
           & "Letters & Faxes\" & sTemplateName, _
           Range:=sFooter, _
           ConfirmConversions:=False, Attachment:=False, Link:=False
   Next iCount
End Sub

Function WorkGroupPath() As String
'   Written by Charles Kenyon
'   February 28, 2003
'
'   Used by templates menus to set location of templates.
'   Returns workgroup tempates path with "\" at the end.
'
'   This is needed because if the folder is a network drive rather
'   than a folder, it will have the "\" already. If it is a folder,
'   it will not have the backslash. This function gives a string
'   with the backslash in either case.
'
   WorkGroupPath =
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
   If Right(WorkGroupPath, 1) <> "\" Then
       WorkGroupPath = WorkGroupPath & "\"
   End If
End Function

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.

>I have a letterhead template that has a text box inserted and locked in
> position outside of the bounding area of the header area that holds the
[quoted text clipped - 17 lines]
> Thanks,
> Brent
 
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.