MAcro to create headers and footers

M

maperalia

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

Thanks.
Maperalia
 
C

Charles Kenyon

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?
--
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.
 
M

maperalia

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
 
C

Charles Kenyon

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.
--
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.
 
J

JML

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,
 

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

Top