Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I create a particular macro in Word 2007

Posted on 2011-10-06
7
Medium Priority
?
252 Views
Last Modified: 2012-05-12
Right now to create a numbered procedure I have to:

1, Select numbering from number icon of the form:

1.
2.
Etc

2 then I do left indent to make it flush left

3. Then I select spacing of 1.5.

Result:

1.

2.

etc.


Question: How can I do this with a macro?


0
Comment
Question by:bark1
  • 4
  • 3
7 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 36930108
Have you tried recording a macro. That should work, but the code will be unnecessarily long because it sets the default values for all possible properties.

So here is a simple macro:

 
Sub SetUpParagraphs()
    With Selection
       .Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
            ListGalleries(wdNumberGallery).ListTemplates(1)
        .ParagraphFormat.LeftIndent = CentimetersToPoints(0)
    End With
End Sub

Open in new window


However you could create a new style instead, which might be easier to use that a macro.

With the modified text selected, open the 'Styles' window with the tiny arrow at the bottom-right of the 'Styles' group on the 'Home' tab. The bottom-left icon on the 'Styles' window is the 'New Style' button.
0
 

Author Comment

by:bark1
ID: 36931847
Hi GrahamSkan,

Thanks for prompt response. Both methods you gave me work fine--up to a point. That is, when I go to start a new list, they both start with the continuous number from the old list-they do not start at 1required for the new procedure.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36932174
The .ApplyListTemplateWithLevel Method has an argument (ContinuePreviousList) for that

Sub SetUpParagraphs()
    With Selection
       .Range.ListFormat.ApplyListTemplateWithLevel _
            ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(1), _
            ContinuePreviousList:=False
        .ParagraphFormat.LeftIndent = CentimetersToPoints(0)
    End With
End Sub

Open in new window

0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 

Author Comment

by:bark1
ID: 36933940
Thanks.

Almost there.

I need line spacing of 1.5. Could you modify the code to do this?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36934017
LinsSpacing is a property of the ParagraphFormat object, but is measured in Points, so we need to convert the lines value into Points
Sub SetUpParagraphs()
    With Selection
       .Range.ListFormat.ApplyListTemplateWithLevel _
            ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(1), _
            ContinuePreviousList:=False
        With .ParagraphFormat
            .LeftIndent = CentimetersToPoints(0)
            .LineSpacing = LinesToPoints(1.5)
        End With
    End With
End Sub

Open in new window

0
 

Author Comment

by:bark1
ID: 36936452

Hi Graham,

I punched the VB code in and got an error I tried to run it. See attached file.

Thanks.

enus-1-.html
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36936771
What is the number and text of the error message, and what line does it fail on, please? The link doesn't seem to be very relevant.

Also for the sake of future users, it is good to be able to use the text search to pick up errors, and it can't look inside pictures or links.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Wow it feels like forever since I have been able to sit down and write an article, I have been away and new exciting projects keeping me busy, but here I am writing another hopefully informative article. I have written about Orchestrator 2012 int…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
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 …

810 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