Jump to content

Recommended Posts

Posted (edited)

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)

 

folder_content.png.12f97316331cb258bcfb4c2dfb1353b2.pngerror_attaching.png.615b134de7915ea51b98892e89ff0873.png

 

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

Edited by Skysnake
Typo

Skysnake

Why is the snake in the sky?

Posted

If you want to open a word document with your AutoIt script: use _Word_DocOpen.
If you want to process a word document which has already been opened by the user: use _Word_DocAttach.

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Ah. I understand now. Sorry, I completely misunderstood the example and the purpose of that example.

Skysnake

Skysnake

Why is the snake in the sky?

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

  • 1 year later...
Posted

What is this post for? It is unrelated to the topic and you do not even post a question?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

The spammers get lazier each day. A few years ago they at least tried to sell me viagra ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Developers
Posted (edited)

These days they create profiles and hide the advertising in their profile assuming they don't get caught. I zap around 1-2 members a day that uses this method.

Jos

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I see :)

I hope you all get rewarded by Jon (🍺🥃🍷🥂) for your daily moderation tasks - which mostly go unnoticed by the ordinary user👍

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Seems you get praised from sunrise to sunset 🤔

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Because they know I no longer need viagra - I started to play golf :D

My UDFs and Tutorials:

  Reveal hidden contents

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...