Solved

Problem with Word Macro

Posted on 2011-09-28
2
336 Views
Last Modified: 2012-05-12
Hi

I am trying to create a macro in word that would setup page margins and fonts etc and make it look like the attached.  But when I run it the box appears to the left next to the text and not where I want it.

The vba is
Sub InsertGraph()
'
' InsertGraph Macro
 
    Dim shp As Word.Shape
    Application.Run MacroName:="BulletsAndHeadings"
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
     Set shp = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 150, 210, 242, 259)
    Selection.TypeText Text:="Source:"
    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
    Selection.Font.Grow
    Selection.Font.Size = 7.5
End Sub

Open in new window

BulletsAndHeading is a separate macro and page layout is 2 column. Basically, I need a way to right align the shape.

Any ideas?

many thanks
 
Word.jpg
0
Comment
Question by:kenabbott
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
This macro shows how to right-align a shape.
Sub Rightshape()
    Dim shp As Shape
    
    Set shp = ActiveDocument.Shapes(1)
    shp.RelativeHorizontalPosition = wdRelativeHorizontalPositionRightMarginArea
    shp.Left = -shp.Width
End Sub

Open in new window

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
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 …

772 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

10 Experts available now in Live!

Get 1:1 Help Now