Search the Community
Showing results for tags '_word_docattach'.
-
Hi Everyone First time I post in the Office section. Problem I have is that I can't figure out the _Word_DocAttach() Helpfile function. I think the HelpFile example may not actually work. What is it supposed to do? Concatenate Test.doc to itself? #include <MsgBoxConstants.au3> #include <Word.au3> ; Create application object Local $oWord = _Word_Create() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open test document read-only $sDocument = @ScriptDir & "\MyLetterHead.docx" _Word_DocOpen($oWord, $sDocument, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Error opening '.\Extras\Test.doc'." & _ @CRLF & "@error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Attach to the test document by "FileName" and set focus to the window ; ***************************************************************************** ;$Body = @ScriptDir & "\MyLetterBody1.docx" ;$Body = "MyLetterBody1.docx" $Body = "Test.doc" Local $oDoc = _Word_DocAttach($oWord, "Test.doc", "Filename") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _ "Error attaching to '"&$sDocument&"' by '"&$Body&"'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Set focus to the word document - $f_takeFocus parameter of the old _WordCreate function WinActivate($oWord.ActiveWindow.Caption & " - " & $oWord.Caption) MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Attach to document by 'FileName' successfull!" & @CRLF & _ @CRLF & "Text of the attached document:" & @CRLF & $oDoc.Range().Text) I have (in the same folder) @ScriptDir my AutoIt script (above), as well as the two Word DocX files. That Test.doc is actually the file from the AutoIt HelpFile install... My understanding of the syntax is Local $oDoc = _Word_DocAttach($oWord, "Test.doc", "Filename") --> use the Object $oWord (previously opened) --> and attach to it the document "Test.doc" which you search for based on its Filename I can't get this to work. Skysnake