Sign in to follow this  
Followers 0
ddjenkins

_Word_DocOpen problems

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



Have you tried:

Global $sDocument = $sFilePathOrigin & $sFileName

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

I just tried it & yes that now works, howver, the problem then is it cannot handle file with spaces like "An example name.doc"

Share this post


Link to post
Share on other sites

I will check.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0