Solved Highlight?


here. this AHK will do it for you. save the attached .zip, extract the EXE and pin it to your taskbar (just for ease of access). it will:

- Prompt for Start Page
- Prompt for End Page
- Tell you to bring Word Document to Active window, then click OK on prompt
- Highlight from the Bottom of the End Page to the Top of the Start Page

content of EXE:
Code:
#SingleInstance Force

; --- Prompt for start page ---
InputBox, PageStart, Start Page, Enter the START page number:, , 250, 150
if ErrorLevel
    ExitApp

; --- Prompt for end page ---
InputBox, PageEnd, End Page, Enter the END page number:, , 250, 150
if ErrorLevel
    ExitApp

; --- Prompt to activate Word (always on top) ---
MsgBox, 0x40000, Activate Word, Activate the Word window, then press OK.

WinWaitActive, ahk_exe WINWORD.EXE, , 5
if ErrorLevel {
    MsgBox, 16, Error, Word window was not activated.
    ExitApp
}

try {
    word := ComObjActive("Word.Application")
} catch {
    MsgBox, 16, Error, Could not connect to Word. Make sure a document is open.
    ExitApp
}

; Ensure Print Layout
word.ActiveWindow.View.Type := 3   ; wdPrintView

; --- Go to END page ---
word.Selection.GoTo(1, 1, PageEnd)   ; wdGoToPage = 1
word.Selection.EndKey(6)             ; wdStory = 6 (end of page/section)

; --- Shift+PAGE UP to end of START page ---
Loop
{
    currentPage := word.Selection.Information(3) ; wdActiveEndPageNumber = 3
    if (currentPage <= PageStart)
        break
    SendInput, +{PgUp}
    Sleep, 30
}

; --- Shift+UP to the TOP of the start page ---
Loop
{
    prevPage := word.Selection.Information(3)
    SendInput, +{Up}
    Sleep, 10
    newPage := word.Selection.Information(3)

  
    if (newPage < prevPage) {
        SendInput, +{Down}
        break
    }


    if (word.Selection.Information(7) = 1)  ; wdVerticalPositionRelativeToPage
        break
}

; --- Apply highlight ---
word.Selection.Range.HighlightColorIndex := 7  ; Yellow

MsgBox, 64, Done, Highlight applied from page %PageStart% to %PageEnd%.
ExitApp
 

Attachments

My Computer

System One

  • OS
    Windows 11 Pro
You could highlight each selection and cut and paste into a new document. That's how I do it.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 25H2 26200.8655
    Computer type
    Laptop
    Manufacturer/Model
    Acemagic LX15PRO
    CPU
    AMD Ryzen 7 5825U with Radeon Graphics
    Memory
    16GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD 2TB
    Internet Speed
    30 Mbps
    Browser
    Brave
    Antivirus
    Webroot Secure Anywhere
    Other Info
    System 3

    Acer Swift SF114-34 laptop
    OS Windows 11 Pro 26200.8524
    CPU Pentium Silver N6000
    RAM 4GB
    SSD Samsung 970 EVO Plus SSD 2TB (an upgrade)
  • Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
here. this AHK will do it for you. save the attached .zip, extract the EXE and pin it to your taskbar (just for ease of access). it will:

- Prompt for Start Page
- Prompt for End Page
- Tell you to bring Word Document to Active window, then click OK on prompt
- Highlight from the Bottom of the End Page to the Top of the Start Page

content of EXE:
Code:
#SingleInstance Force

; --- Prompt for start page ---
InputBox, PageStart, Start Page, Enter the START page number:, , 250, 150
if ErrorLevel
    ExitApp

; --- Prompt for end page ---
InputBox, PageEnd, End Page, Enter the END page number:, , 250, 150
if ErrorLevel
    ExitApp

; --- Prompt to activate Word (always on top) ---
MsgBox, 0x40000, Activate Word, Activate the Word window, then press OK.

WinWaitActive, ahk_exe WINWORD.EXE, , 5
if ErrorLevel {
    MsgBox, 16, Error, Word window was not activated.
    ExitApp
}

try {
    word := ComObjActive("Word.Application")
} catch {
    MsgBox, 16, Error, Could not connect to Word. Make sure a document is open.
    ExitApp
}

; Ensure Print Layout
word.ActiveWindow.View.Type := 3   ; wdPrintView

; --- Go to END page ---
word.Selection.GoTo(1, 1, PageEnd)   ; wdGoToPage = 1
word.Selection.EndKey(6)             ; wdStory = 6 (end of page/section)

; --- Shift+PAGE UP to end of START page ---
Loop
{
    currentPage := word.Selection.Information(3) ; wdActiveEndPageNumber = 3
    if (currentPage <= PageStart)
        break
    SendInput, +{PgUp}
    Sleep, 30
}

; --- Shift+UP to the TOP of the start page ---
Loop
{
    prevPage := word.Selection.Information(3)
    SendInput, +{Up}
    Sleep, 10
    newPage := word.Selection.Information(3)

 
    if (newPage < prevPage) {
        SendInput, +{Down}
        break
    }


    if (word.Selection.Information(7) = 1)  ; wdVerticalPositionRelativeToPage
        break
}

; --- Apply highlight ---
word.Selection.Range.HighlightColorIndex := 7  ; Yellow

MsgBox, 64, Done, Highlight applied from page %PageStart% to %PageEnd%.
ExitApp
I enter the start and end page but it highlights all? strange.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 25H2 (26200.8457).
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron i5 5510
    CPU
    core i7 11th gen
    Memory
    16 GB DDR4 @3200 MHz
    Hard Drives
    1 TB SSD M.2 NVMe
    Keyboard
    Dell Premier Multi-Device Wireless Keyboard and Mouse – KM7321W
    Browser
    Brave.
    Other Info
    Edifier speakers. (Thanks to @Edwin).
  • Operating System
    W11 25H2 (26200.7840)
    Computer type
    PC/Desktop
    Manufacturer/Model
    XPS Special Edition
    CPU
    11th Gen Intel® Core i7-11700 processor
    Memory
    32 GB, 2 x 16 GB, DDR4, 2933 MHz, dual channel
    Graphics card(s)
    NVIDIA GeForce RTX 3060 12GB GDDR6
    Hard Drives
    2TB M.2 PCIe NVMe SSD
I enter the start and end page but it highlights all? strange.
I tested on a 100pg and a 150pg word docs an both stop at the top of the Start page (example - page 3 or page 8 etc) and I don’t have that issue…
 

My Computer

System One

  • OS
    Windows 11 Pro
I tested on a 100pg and a 150pg word docs an both stop at the top of the Start page (example - page 3 or page 8 etc) and I don’t have that issue…

It says highlight applied from page 5 to page 150 But its not highlighted?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 25H2 (26200.8457).
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron i5 5510
    CPU
    core i7 11th gen
    Memory
    16 GB DDR4 @3200 MHz
    Hard Drives
    1 TB SSD M.2 NVMe
    Keyboard
    Dell Premier Multi-Device Wireless Keyboard and Mouse – KM7321W
    Browser
    Brave.
    Other Info
    Edifier speakers. (Thanks to @Edwin).
  • Operating System
    W11 25H2 (26200.7840)
    Computer type
    PC/Desktop
    Manufacturer/Model
    XPS Special Edition
    CPU
    11th Gen Intel® Core i7-11700 processor
    Memory
    32 GB, 2 x 16 GB, DDR4, 2933 MHz, dual channel
    Graphics card(s)
    NVIDIA GeForce RTX 3060 12GB GDDR6
    Hard Drives
    2TB M.2 PCIe NVMe SSD
ive tested it 20+ times on different word documents. it works...

But doesn't work on my MS word doc., when I enter start and end it highlighligts all + 3000 pages and acts erratic.

Thanks.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 25H2 (26200.8457).
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron i5 5510
    CPU
    core i7 11th gen
    Memory
    16 GB DDR4 @3200 MHz
    Hard Drives
    1 TB SSD M.2 NVMe
    Keyboard
    Dell Premier Multi-Device Wireless Keyboard and Mouse – KM7321W
    Browser
    Brave.
    Other Info
    Edifier speakers. (Thanks to @Edwin).
  • Operating System
    W11 25H2 (26200.7840)
    Computer type
    PC/Desktop
    Manufacturer/Model
    XPS Special Edition
    CPU
    11th Gen Intel® Core i7-11700 processor
    Memory
    32 GB, 2 x 16 GB, DDR4, 2933 MHz, dual channel
    Graphics card(s)
    NVIDIA GeForce RTX 3060 12GB GDDR6
    Hard Drives
    2TB M.2 PCIe NVMe SSD
But doesn't work on my MS word doc., when I enter start and end it highlighligts all + 3000 pages and acts erratic.

Thanks.
doesnt make any sense why it wouldnt. if you want it resolved, you're going to have to post a clip that shows what its doing. i cant replicate the issue using that ahk.
 

My Computer

System One

  • OS
    Windows 11 Pro
doesnt make any sense why it wouldnt. if you want it resolved, you're going to have to post a clip that shows what its doing. i cant replicate the issue using that ahk.

I agree with you with regards to posting BUT its patient personal data included in too.

Thanks anyways still when I type page 3450 to 5950 it begins at a slow pace from the very bottom slowly going upwards but not from the end page but end of MS Word doc. And its speed is the same as I use thee mouse to highlight.... maybe my laptop cannot handle it, has low resources??
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 25H2 (26200.8457).
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron i5 5510
    CPU
    core i7 11th gen
    Memory
    16 GB DDR4 @3200 MHz
    Hard Drives
    1 TB SSD M.2 NVMe
    Keyboard
    Dell Premier Multi-Device Wireless Keyboard and Mouse – KM7321W
    Browser
    Brave.
    Other Info
    Edifier speakers. (Thanks to @Edwin).
  • Operating System
    W11 25H2 (26200.7840)
    Computer type
    PC/Desktop
    Manufacturer/Model
    XPS Special Edition
    CPU
    11th Gen Intel® Core i7-11700 processor
    Memory
    32 GB, 2 x 16 GB, DDR4, 2933 MHz, dual channel
    Graphics card(s)
    NVIDIA GeForce RTX 3060 12GB GDDR6
    Hard Drives
    2TB M.2 PCIe NVMe SSD
Back
Top Bottom