Solved

Problem with Word Macro

Posted on 2011-09-28
2
339 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
ID: 36814781
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
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…
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 …

816 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

6 Experts available now in Live!

Get 1:1 Help Now