Column width at the current selection 
Author Message
 Column width at the current selection

I've been using the following in Word 9 to get the width of the page column
at the current selection, not in a table. I do not want the page width, just
the column width:

sngColumnWidth = PointsToInches(Selection.PageSetup.TextColumns(1).Width)

Is that the proper way to retrieve such info?
The code works in Word 9, but not in Word 8.

Word 8 gives Run-time error 5993: "Cannot set width or spacing when there is
only one text column."

I would consider that message to be a bug, since I am not SETting anything.
Is there another way to code this that works in both Word 8 and Word 9?

My ugly workaround is:

If Selection.PageSetup.TextColumns.Count = 1 Then
    sngColumnWidth = PointsToInches(Selection.PageSetup.TextColumns.Width)
Else
    sngColumnWidth =
PointsToInches(Selection.PageSetup.TextColumns(1).Width)
End If
--
Please post your response to the newsgroup.

http://www.*-*-*.com/ ; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------



Mon, 20 Oct 2003 15:33:01 GMT  
 Column width at the current selection
Hello Howard,

Unless set to multiple columns, Word documents consist of 1 column
automatically spaced out to fit between the existing margin settings for
the
current paper size. If you try to set the column width for 1 column, this
will
generate an error because Word is using its builtin functionality in order
to
size it correctly.  That functionality can't be overwritten by a VBA macro.
The column width is paper size minus margins.

There was a bug in Word 97 associated with returning the value of the
column.
That was corrected in Word 2000. Your suggested code is about as
succinct as it can be to work around the differences between the two
versions.



Mon, 20 Oct 2003 21:10:36 GMT  
 Column width at the current selection
Ayup, but the code was supposed to work, no matter how many columns, so I
just needed to determine the width of the column containing the current
selection.

The message in Word 8 is a bad bug, as I am not setting any value, just
retrieving a value.
A sign of inadequate SQA process in MSFT.

--
Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------

Quote:
> Hello Howard,

> Unless set to multiple columns, Word documents consist of 1 column
> automatically spaced out to fit between the existing margin settings for
> the
> current paper size. If you try to set the column width for 1 column, this
> will
> generate an error because Word is using its builtin functionality in order
> to
> size it correctly.  That functionality can't be overwritten by a VBA
macro.
> The column width is paper size minus margins.

> There was a bug in Word 97 associated with returning the value of the
> column.
> That was corrected in Word 2000. Your suggested code is about as
> succinct as it can be to work around the differences between the two
> versions.



Mon, 20 Oct 2003 23:50:41 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Text column of current selection

2. Setting datagrid column width sets width of toplevel!!

3. Set Grid width to sum of Column Widths

4. ListView column width = ListView width ?

5. Total width of columns = Width of ListView

6. Total width of columns = Width of ListView

7. Make dbgrid columns width follow form width ???

8. Total width of columns = Width of ListView

9. Total width of columns = Width of ListView

10. Error creating rows with columns having different column width

11. Multi Column TextBox Column Widths

12. FlexGrid Merge Columns: Row/Column selection inconsistant?!?!

 

 
Powered by phpBB® Forum Software