Getting the value of hanging indent

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

The VBA help file shows how to set a hanging indent:

ActiveDocument.Paragraphs(1).TabHangingIndent(2)

The "2" signifies that the hanging indent is set with the value of the second
tab stop. What I need to do is read this value for a selected paragraph--
that is, what tab stop is used as the hanging indent for this paragraph? VBA
always seems to make the "get" function obscure. I've tried lines like this:

' Gives message "Argument not optional"
TabNumUsedForHang = Selection.Paragraphs(1).TabHangingIndent

' Gives message "Object does not support this object or method"
TabNumUsedForHang = Selection.ParagraphFormat(1).TabHangingIndent

Can someone show me how to get this value? I'd like to add a function like
Value( ) around this just to see what the setting is. Thanks for any help.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200701/1
 
S

Stefan Blom

A hanging indent would correspond to a negative value for the
FirstLineIndent property in a ParagraphFormat object.

For example: If Selection.ParagraphFormat.LeftIndent equals 20, and
Selection.ParagraphFormat.FirstLineIndent equals -20, then the first
line of text starts at the left margin, and the rest of lines starts
at 20 pt from the left margin (this is also where the tab stop is
located).

Another example: If LeftIndent = -20 and FirstLineIndent = -20, then
the first line starts at -40 pt and the rest of lines at -20 pt.

The hanging indent is always relative to the LeftIndent value.

--
Stefan Blom
Microsoft Word MVP


in message
news:6cae557c9e4aa@uwe...
 
C

christophercbrewster via OfficeKB.com

Thanks for the response. I'm still unclear on how the code can determine the
hanging indent. Would it have to use both the LeftIndent and FirstLineIndent
values? To *set* the value, using either the code or the GUI, just uses a
simple number, and I'm trying to read that number back.

Stefan said:
A hanging indent would correspond to a negative value for the
FirstLineIndent property in a ParagraphFormat object.

For example: If Selection.ParagraphFormat.LeftIndent equals 20, and
Selection.ParagraphFormat.FirstLineIndent equals -20, then the first
line of text starts at the left margin, and the rest of lines starts
at 20 pt from the left margin (this is also where the tab stop is
located).

Another example: If LeftIndent = -20 and FirstLineIndent = -20, then
the first line starts at -40 pt and the rest of lines at -20 pt.

The hanging indent is always relative to the LeftIndent value.
The VBA help file shows how to set a hanging indent:
[quoted text clipped - 10 lines]
' Gives message "Object does not support this object or method"
TabNumUsedForHang = Selection.ParagraphFormat(1).TabHangingIndent

Can someone show me how to get this value? I'd like to add a function like
Value( ) around this just to see what the setting is. Thanks for any help.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200701/1
 
S

Stefan Blom

As I wrote, a negative value for FirstLineIndent indicates a hanging
indent. The exact position of text (relative to the margin) can only
be determined by also looking at the LeftIndent property.

In other words, there is nothing that directly corresponds to the
setting in the Paragraph dialog box (no "HangingIndent" property).

Note that the TabHangingIndent method can only be used to *set* a
hanging indent, not return an existing one. It is the equivalence of
the Ctrl+T shortcut in the user interface.

--
Stefan Blom
Microsoft Word MVP


in message
Thanks for the response. I'm still unclear on how the code can determine the
hanging indent. Would it have to use both the LeftIndent and FirstLineIndent
values? To *set* the value, using either the code or the GUI, just uses a
simple number, and I'm trying to read that number back.

Stefan said:
A hanging indent would correspond to a negative value for the
FirstLineIndent property in a ParagraphFormat object.

For example: If Selection.ParagraphFormat.LeftIndent equals 20, and
Selection.ParagraphFormat.FirstLineIndent equals -20, then the first
line of text starts at the left margin, and the rest of lines starts
at 20 pt from the left margin (this is also where the tab stop is
located).

Another example: If LeftIndent = -20 and FirstLineIndent = -20, then
the first line starts at -40 pt and the rest of lines at -20 pt.

The hanging indent is always relative to the LeftIndent value.
The VBA help file shows how to set a hanging indent:
[quoted text clipped - 10 lines]
' Gives message "Object does not support this object or method"
TabNumUsedForHang = Selection.ParagraphFormat(1).TabHangingIndent

Can someone show me how to get this value? I'd like to add a function like
Value( ) around this just to see what the setting is. Thanks for
any help.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200701/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top