• Status Bar Variables (97+)

    Author
    Topic
    #364221

    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

    Viewing 0 reply threads
    Author
    Replies
    • #558413

      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

      • #558445

        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

        • #558450

          Look at the help for Selection.Information( )

          Things you might need are

          wdFirstCharacterColumnNumber for the column number
          wdFirstCharacterLineNumber for the line number, but will give you -1 if background pagination is on
          wdActiveEndPageNumber for the page number of the end of the selection

          StuartR

          • #558453

            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

            • #558454

              > I assume your 2nd item should have had Line in it.
              It does now smile

              This seems to work for me…

                 
                  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(wdVerticalPositionRelativeToPage)
                    ' 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
                 
              

              StuartR

            • #558482

              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(wdVerticalPositionRelativeToPage)

              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

            • #558484

              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

            • #558490

              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

    Viewing 0 reply threads
    Reply To: Status Bar Variables (97+)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: