?
Solved

MS macro

Posted on 2013-01-25
1
Medium Priority
?
197 Views
Last Modified: 2013-01-30
I want to build a macro that can change different documents so that they all are in the same template. for example change font, size and add header and footer.

Anyone know a good way to do this. I think i can do the code i just don't know how it should work?? Any ideas
0
Comment
Question by:j8547
1 Comment
 
LVL 23

Accepted Solution

by:
redrumkev earned 2000 total points
ID: 38833842
j8547,

How are you doing?

You can achieve this in numerous ways, something as simple as:
    Selection.Font.Name = "Times New Roman" 
    Selection.Font.Size = 10 

Open in new window

Allows you to change all text to "Times New Roman" and "10" size.

As for your headers/footers, something along the lines of:
Sub EditHeadersAndFooters()

Dim i As Long

For i = 1 To ActiveDocument.Sections.Count
    With ActiveDocument.Sections(i)
        .Headers(wdHeaderFooterPrimary).Range.Text = "HeaderText"
        .Footers(wdHeaderFooterPrimary).Range.Text = "FooterText"
    End With
Next

End Sub

Open in new window

Might work - replacing "HeaderText" with whatever you want in the header and "FooterText" with whatever you want in the Footer.

These are basic examples but should allow you to get started. If you run into issues or wish to make these more complex, such as adding page numbers, referencing sections of the document differently, then please post a new question with whatever code you have created and we can build on that to get you all squared away!

Hope this helps,
Kevin
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question