wardw Posted June 19, 2013 Posted June 19, 2013 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.
DW1 Posted June 19, 2013 Posted June 19, 2013 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 & '"') AutoIt3 Online Help
water Posted June 19, 2013 Posted June 19, 2013 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: Reveal hidden contents 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