Solved

Right-aligning a shape in Word97

Posted on 2000-02-28
16
324 Views
Last Modified: 2008-02-01
I'd like to align a shape (typically a bitmap image) that is not in-line(!) flush right on a page or in a text column. Word6 could do this. Word97 can't (at least I have found no way to do so). I have tried lots of things. I can right-align a shape on a "plain" page, but text columns give me a big headache. So if there is no "easy" solution that I simply overlooked, please focus on aligning an image (not in-line!) right in the second (!) column of 3 on a page when the columns have different widths.

Thanks in advance,
Wolfgang <><
0
Comment
Question by:hutter
  • 9
  • 3
  • 2
  • +2
16 Comments
 
LVL 22

Expert Comment

by:ture
Comment Utility
I'm using Word 2000, doing this without problems.

1. I create a three-column document with different sized columns.

2. I type some text into columns 1 and 2, with a column break to end column 1.

3. I insert a clip-art picture into column 2.

4. Double-click the clip-art, and set:
Layout tab: Wrapping style: Tight, Horizontal Alignment: Right.

Done!

Ture Magnusson
Karlstad, Sweden
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Wolfgang,

I tried the procedure in Word 97, and noticed that there are not the same possibilities there. A reason to upgrade to Word 2000...

/Ture
0
 
LVL 3

Expert Comment

by:eal4
Comment Utility
Ture and Wolfgang,
In Word 97, you have to go to Format, Object in order to accomplish what you wish. Try it out.
Ed
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Ed,

I have done that, but the formatting options are not the same as in Word 2000. I can't find a way there to set the picture's horizontal alignment to Right.

/Ture
0
 
LVL 1

Author Comment

by:hutter
Comment Utility
Ture,

upgrade??? Downgrade!!! As I said: it was possible in Word97!

I crossposted this question to the VBA area and am hoping for additional insight from there...
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
hutter,

You wrote "Word6 could do this".

Word 97 can't (or at least not in a way that I know of). That's not good.

Word 2000 does it, nicely and easily. That IS an upgrade from Word 97!

/Ture
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Wolfgang,

As you have posted your question also in the VB topic area, can I assume that a VBA solution is OK? Like selecting the image and then running a VBA procedure to position the selected image correctly?

/Ture
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Wolfgang,

This VBA procedure right-aligns an image within a column:

Sub PutImageRightAlignedInColumn()
  Dim img As ShapeRange
  Dim col As TextColumn
  Dim colLeft As Long
  Dim colRight As Long
 
  Set img = Selection.ShapeRange
  img.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
 
  For Each col In ActiveDocument.PageSetup.TextColumns
    colRight = colLeft + col.Width
    If img.Left >= colLeft And img.Left <= colRight Then
      img.Left = colRight - img.Width
      Exit Sub
    End If
    On Error Resume Next
    colLeft = colRight + col.SpaceAfter
    On Error GoTo 0
  Next col
End Sub

/Ture
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:hutter
Comment Utility
cross-post from VBA area

Hi Ture,

                      not bad. But I see that you seem to have needed to use a workaround for a problem that  also encountered. You check for the
                      column in which the image is located by asking if the left border of the image is betwee the column boundaries. Nice try. But
                      what if the image is located just a tiny bit left of the border? Then it is shifted to the previous column.

                      Still worse: if the left border does lie in the space between the columns or to the left of the first one it is not moved at all.

                      This whole problem reflects (IMHO) the difficulties in determining to which column the shape is anchored. Can anybody tell me
                      how to determine the index of the text column I am in?

                      Many VBA functions (at least the examples) refer only to constructs like Object(index),but the online help does not tell me how
                      to find out what "index"  is! Selection.Infrmation helps a little with regard to tables, but how do you find out in which paragraph
                      your selection is?

                      To determine the width of the current text column I tried to use an empty paragraph in that column, right align it and use
                      Selection.Information(wdHorizontalPositionRelativeToTextBoundary). But guess what: this function does not return the value of
                      the current text column, but the value for the first txt column!

                      Example: 3 columns, 4.5 - 6.13 - 2.87 centimeters with a spacing of 1.25 centimeters and a left margin of 2.5 centimeters.
                      Selection.Information(wdHorizontalPositionRelativeToTextBoundary) gives 4.5 centimeters for a paragrph right aligned in the
                      second column!!!

                      The same for Selection.Information(wdHorizontalPositionRelativeToPage). This gives 12.76 cm which is exactly the left margin
                      plus the spacig between the columns plus two times the width of the first column.

                      A bug or a feature???
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Wolfgang,

Actually, my VBA procedure seems to do a better job than the built-in rightalign feature in in Word 2000.  In Word 2000, I am having problems right-aligning my picture in the last column.

My procedure consistently puts the image right-aligne in the column where the left edge of the picture is. If you prefer right-aligning the image in the column where its right border is, use this slightly modified procedure.

Sub PutImageRightAlignedInColumn()
  Dim img As ShapeRange
  Dim col As TextColumn
  Dim colLeft As Long
  Dim colRight As Long
   
  Set img = Selection.ShapeRange
  img.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
 
  For Each col In ActiveDocument.PageSetup.TextColumns
    colRight = colLeft + col.Width
    If img.Left + img.Width >= colLeft And img.Left + img.Width <= colRight Then
      img.Left = colRight - img.Width
      Exit Sub
    End If
    On Error Resume Next
    colLeft = colRight + col.SpaceAfter
    On Error GoTo 0
  Next col
End Sub


I also tried stuff like img.Anchor.Information(wdHorizontalPositionRelativeToPage), with the same disappointing results as you ended up with. I really can't see this as a 'feature'.

/Ture
0
 

Expert Comment

by:shottarum
Comment Utility
Try right clicking on the bitmap image and go to format picture, hit the layout tab and choose either in front of or behind text, change your horizantal alignment to right and then click O.K.

- SHOTTARUM SAYS SO
0
 
LVL 17

Expert Comment

by:calacuccia
Comment Utility
CALACUCCIA SAYS TO SHOTTARUM:

If all you can do is copy comments from others an post them as an answer, you won't get far.

Read what is written above, EVERYTHING, and come to the conclusion you just have added some overflow data to this discussion of no value at all and have pulled out the anger of some people.
0
 

Expert Comment

by:shottarum
Comment Utility
SHOTTARUM SAY TO CALACUCCIA:

You need to answer the question yourself, and stop pulling anger out of your ________, because SHOTTARUM does not welcome your rude comment.  Please give constructive critisicm only.  

SHOTTARUM SAYS TO HUTTER:

I'm sorry that I could'nt help you, however I just misread your question.  Good Luck in finding the correct answer.

0
 
LVL 22

Accepted Solution

by:
ture earned 300 total points
Comment Utility
Upgrading to answer.

I have done a bit of research on this, and it really seems as if there is no easier way to find out the number of the selection's column.
0
 
LVL 1

Author Comment

by:hutter
Comment Utility
How do you rate an unsatisfactory answer when the grade of satisfaction does not depend on the answer, but on the limitation Micro$oft imposes on it... Sigh...
0
 
LVL 22

Expert Comment

by:ture
Comment Utility
Wolfgang,

Thanks for the points! I know - it's not easy to know what grade to give for an answer like mine. It's not really the answer you would like to see, but it's the best answer available.

Just to let you know - I have REALLY tried to find a better way.

I have searched the the online help, MSDN and MS KnowledgeBase. I have forwarded this question to Microsoft Word MVP's (a group of people who are very knowledgeable in Microsoft Word and VBA) and Microsoft Support Engineers.

Everywhere, I have found the same answer: There is no simpler way to find the column of a selection. I have received some sample VBA code from the people I discussed this question with, but my own VBA code was really easier than what they sent me.

I certainly hope that Microsoft will add some VBA functionality for this in the next version of Word.

/Ture
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

771 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

11 Experts available now in Live!

Get 1:1 Help Now