Solved

MS macro

Posted on 2013-01-25
1
191 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 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

770 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