rossati Posted January 15, 2016 Posted January 15, 2016 (edited) HelloI would create a KWIC (Key Word in Context) index, and for this I need to access to a paragraph style. But the style returned is empty.I realized this function as Word macro without problems (If anyone is interested can download it from www.condorinformatique.com).Here is a fragment I used:$oWord = _Word_Create() Global $sDocument = "C:\D\Condor\Documentazioni e Progetti\ContextIndexMS\cIndex.doc" $oDoc = _Word_DocOpen($oWord, $sDocument) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _ "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oParag = $oWord.ActiveDocument.Paragraphs $nParag = $oParag.count For $i = 1 To $nParag $style = $oParag($i).Range.ParagraphStyle ConsoleWrite($i & " * *** " & $style & @CRLF) ; ConsoleWrite($oParag($i).Range.Text & @CRLF) Next ; ***************************************************************************** MsgBox($MB_SYSTEMMODAL, "", "See you later alligator.")This is due to the different treatment of variant variables between Autoit and Basic? Thanks for any idea John Rossati Edited January 16, 2016 by rossati I found a solution
rossati Posted January 16, 2016 Author Posted January 16, 2016 Hello The style property, unlike what occurs in Word Basic, it is an object, to which the style name is contained in the property NameLocal. This is the working code: #include <MsgBoxConstants.au3> #include <Word.au3> ; Create application object Local $oRange, $oWord = _Word_Create() Local $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler $oWord = _Word_Create() Global $sDocument = "C:\D\Condor\Documentazioni e Progetti\ContextIndexMS\cIndex.doc" $oDoc = _Word_DocOpen($oWord, $sDocument) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _ "Error opening document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oParag = $oWord.ActiveDocument.Paragraphs $nParag = $oParag.count For $i = 1 To $nParag $style = $oParag($i).Style.NameLocal ConsoleWrite($style & @TAB & $oParag($i).Range.Text & @CRLF) Next ; ***************************************************************************** MsgBox($MB_SYSTEMMODAL, "", "See you later alligator.") Func ErrFunc() ; This is a custom error handler $sHexNumber = Hex($oMyError.number, 8) MsgBox($MB_OK, "", "We intercepted a COM Error at line " & $oMyError.scriptline & @CRLF & _ "Number is: " & $sHexNumber & @CRLF & _ "WinDescription is: " & $oMyError.windescription) EndFunc ;==>ErrFunc
admin19345z Posted November 10, 2016 Posted November 10, 2016 Admin19345z Code19345z Code Translation, Unencrypted=A Encrypted=K A=K B=X C=E D=O E=C F=T G=Q H=P I=V J=M K=G L=D M=I N=Z O=F P=S Q=A R=W S=H T=N U=Y V=U W=J X=B Y=R Z=L After decrypting code via letter translation remove the first 9 letters/numbers of the code which are invalid and replace them with the following 9 letters/numbers. (1) AXhAAAioj (2) 11kefGoMS (3) QQGHd1ydy (4) A2345dqxX
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now