Solved

MS macro

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
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.

862 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

23 Experts available now in Live!

Get 1:1 Help Now