Solved

Problem with Word Macro

Posted on 2011-09-28
2
340 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
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 …

740 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