Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    selection.moveup behavior (2000)

    Here's a good one.

    I've got code like the following:

    appWord.Selection.MoveUp unit:=wdLine, count:=nNumLines

    This code runs--or attempts to run--when appWord.Visible=False (because we're attempting to have the app not intrude on the user's screen). But, with appWord.Visible=FALSE, the code never returns from executing this line. If, however, I set appWord.Visible=TRUE, the same code, on the same document, runs just fine. Does anybody know (a) why this is happening, and ([img]/forums/images/smilies/cool.gif[/img] how I can move up 9 lines from the current selection without using the MoveUp method?

    Thanks...

    Dan

  2. #2
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection.moveup behavior (2000)

    I've figured out a way to move up 'x' lines without using the Selection.Moveup method (see code below). However, I'm still curious about why Word appears to hang when you use MoveUp with Application.Visible=FALSE...Dan

    Public Sub MoveUpLines(objDoc As Document, lNumLines As Long)
    On Error GoTo hErr
    Dim i As Long
    Dim lLineStart As Long

    For i = 1 To lNumLines
    lLineStart = m_appWord.Selection.Bookmarks("Line").Range.Start ' Get start of current line
    ' Move up a line by selecting the range just before the start point of the current line
    objDoc.Range(Start:=lLineStart - 1, End:=lLineStart - 1).Select
    Next


    Exit Sub
    hErr:
    Dim lErrNum As Long
    Dim sErrMsg As String
    Dim lErl As Long
    lErrNum = Err.Number
    sErrMsg = Err.Description
    lErl = Erl
    On Error GoTo 0
    Err.Raise lErrNum, , sErrMsg
    End Sub

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: selection.moveup behavior (2000)

    The Selection object is a property of the ActiveWindow. If the application is running hidden, is there an ActiveWindow? Hmmm... I'll leave that to the philosophers (or someone who has time to play with it.)

Posting Permissions

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