Jump to content

Recommended Posts

Posted

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.

Posted

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 & '"')
Posted

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

 

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