Sign in to follow this  
Followers 0
wardw

Word 2007 files don't open

3 posts in this topic

I'm a new user of AutoIt, and I'd like my first script to open a few files for me. I can open a .txt file and a .pdf file just fine, but when Word opens it can't find the file I've specified. Here's the code I'm using. The same code works fine for the .txt and .pdf files, with file and path modifications:

 

$program_location = "C:Program Files (x86)Microsoft OfficeOffice12WINWORD.EXE"
$file_location = "C:EditingEditing Contract.docx"
Run ( $program_location & " " & $file_location & "")

 

Along with the other two files, Word (2007) opens, but in Word an alert appears: "This file could not be found. (C:EditingEditing.doc)". Clicking OK opens another alert: "This file could not be found. (C:UsersWardDesktopContract.docx)". Clicking OK opens Word with a new, blank document. It looks as if the script has trouble with the space in "Editing Contract.docx", although the other files that open successfully also have spaces in their filenames. Is there a way to comment out the space (I don't want to change the filename).

I'm using Windows 7.

Share this post


Link to post
Share on other sites



It's always a good idea to put file names/locations in quotes.  I usually do this even when there is no space, just as a best practice.

Run ( '"' & $program_location & '" "' & $file_location & '"')

Share this post


Link to post
Share on other sites

Depending on what you try to do with the Word doc there is an UDF (User Defined Functions) available. The UDF that comes with AutoIt doesn't work well with docx files. But there is a WordEX UDF available (for download please see my signature).


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