Solved

Problem with Word Macro

Posted on 2011-09-28
2
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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.

734 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