How can I get a list of all the headings in a Microsoft Word document by using AutoIt?
I tried:
#include <Word.au3>
#include <MsgBoxConstants.au3>
Global Const $wdRefTypeHeading = 1 ; Heading
$Headings = $oDoc.GetCrossReferenceItems($wdRefTypeHeading)
$Count = UBound($Headings)
MsgBox($MB_SYSTEMMODAL, "Debug", $Count)
But it did not function well..
For example, it just get 1 heading from my rich document that have many headings!
I also tried this:
#include <Word.au3>
#include <MsgBoxConstants.au3>
$Count = $oDoc.Paragraphs.Count
For $i = 0 To $Count - 1
$oRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, $i, $wdParagraph, 1)
If StringInStr($oRange.text, "Header Text") Then
MsgBox($MB_SYSTEMMODAL, "Debug", $oRange.Style)
EndIf
Next
And this:
#include <Word.au3>
#include <MsgBoxConstants.au3>
$Count = $oDoc.Paragraphs.Count
For $i = 0 To $Count - 1
$oRange = _Word_DocRangeSet($oDoc, -1, $wdSentence, $i, $wdSentence, 1)
If StringInStr($oRange.text, "Header Text") Then
MsgBox($MB_SYSTEMMODAL, "Debug", $oRange.Style)
EndIf
Next
But the Range.Style property didn't work in AutoIt..
Could someone help me how to get a list of all the headings in a Word document?