How to remove certain rogue blank paragraphs

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
songdg
Posts: 630
Joined: 04 Oct 2017, 20:04

How to remove certain rogue blank paragraphs

Post by songdg » 28 Mar 2024, 21:44

How to remove certain rogue blank paragraphs, I want to remove rogue blank paragraphs from 3 to 8, but keep 1 and 2, that's the rogue blank paragraphs with no text in between.The code written by flyingDman would remove all of them.

Code: Select all

oWord := ComObjActive("Word.Application")
oWord.selection.wholestory
loop oWord.ActiveDocument.Paragraphs.count
	(strlen(oWord.selection.paragraphs.item(a_index).range.text) = 1) && lst .= a_index ","		

if lst ?? ""
	for x,y in strsplit(sort(trim(lst,","),"NRD,"),",")
		oWord.selection.paragraphs.item(y).range.delete()
Attachments
blank.rar
word document
(13.66 KiB) Downloaded 11 times
blandparagraphs.png
blandparagraphs.png (19.44 KiB) Viewed 121 times

Return to “Ask for Help (v2)”