Jump to content

Recommended Posts

Posted

Hi,

I wonder if someone can help me with a problem I'm having with _Word_DocOpen I keep getting an error 2, which is file not found, but I cannot see why.

My code is:

**********************************

Global $oWord = _Word_Create("")
        If @error <> 0 Then Exit
        ; Open document read-only
        Global $sDocument = Chr(39) & $sFilePathOrigin & $sFileName & Chr(39)
        MsgBox($MB_SYSTEMMODAL, "File name", $sDocument)
        Global $oDoc =_Word_DocOpen($oWord, $sDocument, Default, Default, True)
        If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocOpen Example 1", "Error opening " & $sDocument & _
                @CRLF & "@error = " & @error & ", @extended = " & @extended)

**********************************

At the first messagebox "File Name", the path shown as 'C:tempMinutesAGMAGM0108.DOC' which is the correct path & the document does exist

Then the _Word_DocOpen excecutes and I get an error of Error Opening 'C:tempMinutesAGMAGM0108.DOC' @error = 2 @extended = 0

I do not understand why this is happening.

If I run the code

Local $iPID = Run("C:Program Files (x86)Microsoft OfficeOffice14winword.exe " & $sDocument)

It works perfectly. So my path to the document must be correct.

What am I missing? Any help would be great.

Posted

Have you tried:

Global $sDocument = $sFilePathOrigin & $sFileName

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I will check.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I just tried to open a document with spaces and it works without problems.

#include <word.au3>
$oWord = _Word_Create()
Global $sDoc = "C:\temp\Test Leerzeichen.docx"
$oDoc = _Word_DocOpen($oWord, $sDoc)
ConsoleWrite(@error & @LF)

What's the error code after _Word_DocOpen?

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...