Solved

MS macro

Posted on 2013-01-25
1
189 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now