ddjenkins Posted April 5, 2014 Posted April 5, 2014 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.
water Posted April 5, 2014 Posted April 5, 2014 Have you tried: Global $sDocument = $sFilePathOrigin & $sFileName My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
ddjenkins Posted April 7, 2014 Author Posted April 7, 2014 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"
water Posted April 7, 2014 Posted April 7, 2014 I will check. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted April 7, 2014 Posted April 7, 2014 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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