0
votes

Trying to make AHK select a range of text in page # 1. Starting from line 7. Problem is that I never know how many lines the first page will contain, so I can't tell it to move to a certain line. I need it to basically goto the end of the lastline, and then selection.moveup to row 7.

    SetTitleMatchmode, 2
oWord := ComObjActive("Word.Application")
WinActivate, - Word
oWord.Visible := true
oWord.Selection.GoTo(1, 2) ; 1 = GotoPage, 2 = Go to page #

This is getting me to the beginning of page 1. I've tried different things but nothing seems to work as I want. Any ideas?

1
In order to stay within the site guidelines for asking questions (help center) you should not ask more than one thing in a Question. But you can post multiple questions. Use the edit link to modify your question. And please use the ms-word tag, not the word tag - that's something different :-)Cindy Meister

1 Answers

0
votes

I'm not familiar with AutoHotKey, so I'm uncertain how much of the following you can use. But in Word, itself, the following works to:

  1. Go to the page in question
  2. Select the entire page
  3. Move the selection start down 7 lines

"\Page is a built-in bookmark in the Word application that selects the entire page on which the current selection is located.

oWord.Selection.GoTo 1, 1 ; 1 = GotoPage, 2 = Go to page #
oWord.ActiveDocument.Bookmarks("\Page").Range.Select
oWord.Selection.MoveStart 5, 7 ; 5 = wdLine