Solved

MS macro

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

This collection of functions covers all the normal rounding methods of just about any numeric value.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

730 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