Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Status Bar Variables (97+)

    Hi All,

    Some time ago, I recall there was a post that showed how to put things onto the Status Bar. Also the Calculate command puts the results of a calculation on the Status Bar.

    Is there a way to read what is on the Status Bar? If so, is it one long string or are there "variables" for the "standard" items like page number, line number, etc. I saw in the VBA Object Browser that the Application class does have the Status Bar as one of its members. But it's not clear how to get at the information on the SB.

    TIA.

    Fred

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Status Bar Variables (97+)

    I've often written to it with simple commands like

    Statusbar = "text"

    I assumed that you could access the contents with a similar command, but according to the Help file for Word 2000, it is write only.

    StuartR

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Status Bar Variables (97+)

    Stuart,

    Thks for the response. Of course, another approach would be to find the info that is used to create the display on the status bar. Like where the insertion point is (line, col). Other things like page # and section might be easier to find in code but I have a need for the insertion point.

    Fred

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Status Bar Variables (97+)

    Look at the help for Selection.Information( )

    Things you might need are

    <table border=1><td>wdFirstCharacterColumnNumber </td><td>for the column number</td><td>wdFirstCharacterLineNumber</td><td>for the line number, but will give you -1 if background pagination is on</td><td>wdActiveEndPageNumber</td><td>for the page number of the end of the selection</td></table>
    StuartR

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Status Bar Variables (97+)

    Stuart,

    Thks. That's getting me closer - I think.

    I tried displaying some of the items in the VBA Immediate Window. They displayed but the values didn't seem to correspond to what was on the status bar. I tried moving the insertion point around but nothing changed on the Immediate Window.

    Maybe the constants are used differently in the immediate window?

    Can you suggest some code to set variables, say, at_position, line_position and col_position to these constants?

    I assume your 2nd item should have had Line in it.

    Fred

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Status Bar Variables (97+)

    > I assume your 2nd item should have had Line in it.
    It does now <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    This seems to work for me...

    <pre>
    Dim line_position, col_position As Integer
    Dim at_position As Single
    Dim bPagination As Boolean ' Previous state of pagination
    Dim iView As Integer ' Previous view type

    ' Disable background pagination to get line numbers
    bPagination = Options.Pagination
    If Not bPagination Then Options.Pagination = True

    ' Make sure we are in print layout view to get At and Line number
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    iView = ActiveWindow.ActivePane.View.Type
    ActiveWindow.ActivePane.View.Type = wdPrintView
    Else
    iView = ActiveWindow.View.Type
    ActiveWindow.View.Type = wdPrintView
    End If

    at_position = Selection.Information(wdVerticalPositionRelativeTo Page)
    ' Convert to centimeters with one decimal point
    at_position = Round(PointsToCentimeters(at_position), 1)

    line_position = Selection.Information(wdFirstCharacterLineNumber)
    col_position = Selection.Information(wdFirstCharacterColumnNumber )

    ' Reset view and pagination to original values
    Options.Pagination = bPagination

    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = iView
    Else
    ActiveWindow.View.Type = iView
    End If

    MsgBox "At: " & at_position & "cm" & vbCrLf & _
    "Ln: " & line_position & vbCrLf & _
    "Col: " & col_position

    </pre>


    StuartR

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Status Bar Variables (97+)

    Stuart,

    Thks much. Let me give it a shot. Since I don't know much Word VBA, let me ask this:
    at_position = Selection.Information(wdVerticalPositionRelativeTo Page)

    and the other similar statements.

    Does the above imply I have to have a selection? Is it not sufficient to just have the insertion point located at where I want the info from?

    Fred

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Status Bar Variables (97+)

    Fred,

    That shouldn't be a problem - an insertion point is a type of selection, as the following snippet illustrates:

    If Selection.Type = wdSelectionIP Then

    Gary

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Status Bar Variables (97+)

    Gary,

    OK. This looks good. With what you and Stuart gave me, I can get the position info that corresponds to what's on the Status Bar. I think this is all I need. In other words, I don't think I need the page, section, page of pages info. I know I don't need the status of the various toggle buttons (like REC, WPH, etc).

    Fred

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •