Google Answers Logo
View Question
 
Q: MS Word 97 Macro Needed ( No Answer,   5 Comments )
Question  
Subject: MS Word 97 Macro Needed
Category: Computers > Programming
Asked by: google_maniac-ga
List Price: $15.00
Posted: 10 Jan 2006 16:29 PST
Expires: 09 Feb 2006 16:29 PST
Question ID: 431778
I need a macro that will take a series of numbers in a coloumn of a
table and center the largest number using right alignment, and than
give the same alignment to the rest of the numbers in the column. So
basically all the number will be right aligned according to the right
alignment that will center the largest number.  The columns include
numbers and dashes ("-").  The numbers are formated so that commas
separate the hundreds places (2,323,344)...most of the numbers range
from 0 to 99,000. Also, I only want the macro to run on the part of
the table that is highlighted and should work for different sized
columns (some with 2 rows, some with 15, etc.).

The way I guess its gonna have to work it by taking into consideration
the number of digits in the largest number and the width of the
column, and than basically figure out how many points right alignment
would center that...and than apply the same right alignment to the
rest of the highlighted numbers in the column.

Let me know if the price is set to low and I will increase...thanks.

Clarification of Question by google_maniac-ga on 10 Jan 2006 16:46 PST
Yeah sorry I just realized the question is a little confusing..the
alignement of the largest number  has to be right and it has to be
centered using right indentations...all the other numbers in the
column have to be right aligned as well and have the same right
indentation as the largest number...thanks.
Answer  
There is no answer at this time.

Comments  
Subject: Re: MS Word 97 Macro Needed
From: manuka-ga on 10 Jan 2006 17:43 PST
 
Don't know if you can get exactly what you want here, but we can come pretty close.

The problem is that there doesn't seem to be any function to return
the actual width in pixels of a given character or string or whatever.
And relying on the number of digits won't work because different
digits have different widths (depending on the font), and could
potentially be in different point sizes etc. as well.

So we can't just scan the cells and find the widest one, then adjust
everything else to fit. What we can do is note the width of the
column, then autofit it, check the new width, do some calculations and
go from there. However, because we are relying on autofit, there are
some limitations:
 - The cells will be sized and aligned according to the widest value
in the whole column, not just your selection. We should still be able
to limit the effects to the selected range - though it would probably
be simpler to do the whole column.
 - If the table already occupies the full width of the text area,
autofit will do nothing. I also suspect (but haven't checked) that if
autofit would make the table extend beyond the text area, it will only
go up to that limit. In either case, the problem is only an issue if
your largest number is not being displayed on a single line. It sounds
as if in general there will be extra space, so this shouldn't be a
problem.
Subject: Re: MS Word 97 Macro Needed
From: tabspro-ga on 13 Jan 2006 11:35 PST
 
This can be easily done with a few lines of VBA code ..
The macro can be attached to a shortcut key or a button on the toolbar
whenever you wnat to use it..
The code would first Take all the values in the tables in an array ,
convert them into numbers.... compare them... sort them into another
temporary array ... convert each element of the array back into an
string ... and write the whole string back to the table cells ..
The only little complexity here could be in converting the string
values like 120,200,000  into numbers ..coz there is no default
function that can do it , it will have to be converted through a small
custom function that would extract all the comma and then convert the
no into string..
If you want I can do this for you for a little fee.. and even give you
the source code with comments and instructions...
Subject: Re: MS Word 97 Macro Needed
From: google_maniac-ga on 15 Jan 2006 22:13 PST
 
Can you give me an idea of how large a "fee" you are talking about? 
And what about the pronlem that the manuka-ga was refering too..the
fact that different fonts have different point sizes...thanks..
Subject: Re: MS Word 97 Macro Needed
From: nabzofsteel-ga on 20 Jan 2006 02:35 PST
 
I have read what you want to do, Frankly it is too diffcult and a
total waste of time...im guessin you are working at a publishing firm
and you wanna make it easier to Copy and Paste...well i suggest you
just copy and paste and stop finding ways to make this process easier.
The more hours u spend doing it, the more money you make. think about
it, plus Your manager at this publishing firm might know of what you
are trying...=)
Subject: Re: MS Word 97 Macro Needed
From: google_maniac-ga on 31 Jan 2006 12:29 PST
 
From the looks of it...you must be one of those "managers" at a
publishing firm who believes that under production is the key to
corporate america...I suggest that u start producing for the sake of
ur fellow employees and for the sake of the united states' status as
super power..its people like u who are responisble for the US's
excessive need for out sourcing...

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy