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

Tip: Looking for answers? Try searching our database.

MAcro to create headers and footers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maperalia - 04 Nov 2005 01:09 GMT
Can somebody help me to get a macro to load headers and footer automatically.

Thanks.
Maperalia
Charles Kenyon - 04 Nov 2005 01:37 GMT
Probably, but you would be better off creating a template that already has
the headers and footers you want unless they would be different in some
strange way every time you tried to insert them.
http://addbalance.com/usersguide/templates.htm

Even then, the differences could probably be handled by fields.
http://addbalance.com/usersguide/fields.htm

What, exactly, are you trying to accomplish?
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.

> Can somebody help me to get a macro to load headers and footer
> automatically.
>
> Thanks.
> Maperalia
maperalia - 04 Nov 2005 07:40 GMT
Charles;

Thanks for your quick response and the information you sent me.
Basically, I have two template files (Template.xls and Template.doc). The
word file has links information from excel.

What I have is the following:
1.-The template.xls has a description in the cell A1, A2, A3 that are linked
to the template.doc

What I want to accomplish is the following:
1.- Get the information mentioned above and put it automatically in the
header.
2.- The information from cell A1 and A2 will go in the right size of the
header
3.- The information from the cell A3 will go in the left size of the header.

Do you think this is something that could be done with a macro?

Best regards.
Maperalia

> Probably, but you would be better off creating a template that already has
> the headers and footers you want unless they would be different in some
[quoted text clipped - 10 lines]
> > Thanks.
> > Maperalia
Charles Kenyon - 04 Nov 2005 16:33 GMT
Can it be done with a macro? Yes.

Do I know how? No.

I don't try to duplicate regular Word features that are already built into
the program writing complex code unless I have to. Why not just put the
links into the header of your template (manually) and save the template?
Then they will be there in any document created from your template. No code
needed.

The header style is set with a center tab and a right margin tab. You can
position items in a  header using these.
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.

> Charles;
>
[quoted text clipped - 35 lines]
>> > Thanks.
>> > Maperalia
JML - 16 Nov 2005 03:26 GMT
I do something very similar but my Template will only create one new document.
When the template open's up, I have a UserForm pop up with three TextBoxes
and one Command Button. The TextBoxes are "Client Name" = txtName, Client ID#
= txtID, and Client Member Since = txtCMS

The Command button is simply a submit button.

' Tab order
Private Sub UserForm_Activate()
       txtName.SetFocus
       txtName.TabIndex = 0
       txtID.TabIndex = 1
       txtCMS.TabIndex = 2
       cmdHeader.TabIndex = 3
End Sub

Private Sub cmdHeader_Click()
   Unload frmHeader
   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
   Selection.TypeParagraph
   Selection.Font.Bold = wdToggle
   Selection.Font.Italic = wdToggle
   NormalTemplate.AutoTextEntries("New Client, Page #, Date").Insert Where _
       :=Selection.Range, RichText:=True
   Selection.TypeParagraph
   Selection.TypeText Text:=txtName.Text & vbTab & "Member Since: " &
txtCMS.Text & vbTab & "Member ID: " & txtID.Text & vbCrLf
   If Selection.HeaderFooter.IsHeader = True Then
       ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
   Else
       ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   End If
   Selection.Font.Italic = wdToggle
   Selection.Font.Bold = wdToggle
   Selection.TypeText Text:="JML"
   ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

' Document Properties
   With ActiveDocument.CustomDocumentProperties
       .Add Name:="ID", LinkToContent:=False, Type:=msoPropertyTypeNumber,
Value:=txtID.Text
       .Add Name:="Member's Name", LinkToContent:=False,
Type:=msoPropertyTypeString, Value:=txtName.Text
   End With
   vAltDrive = MsgBox("Do you wish save this file to a floppy disk or thumb
drive?", vbQuestion + vbYesNo, "Save file to other folder")
       If vAltDrive = vbYes Then

       Set fd = Application.FileDialog(msoFileDialogSaveAs)
       With fd
           .InitialView = msoFileDialogViewLargeIcons
           .InitialFileName = "E:\Work Briefcase\Clients\" & txtName.Text &
".doc"
       If fd.Show = -1 Then .Execute
       End With
       End If
End Sub

I know this is a just a simple little code (most done with the record
feature - yuk), but it serves my purposes. I imagine that you could have a
UserForm create two documents or somehow pass the code from one document to
another. Sorry about leaving in a bunch of extra stuff like saving to a
floppy drive,

> Can somebody help me to get a macro to load headers and footer automatically.
>
> Thanks.
> Maperalia

Rate this thread:






 
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.