Jump to content

using string variable in run command


 Share

Recommended Posts

I have over 600 microsoft excel files I need to do some editing to and I am trying to write a script to assist with this. I have a list of these files, with the full path, stored in a text file which is read into an array.

My intention is to have AutoIt open each one of these files in succession and I will then have a further part of the script that allows me to highlight certain cells in each spreadsheet, merge the cells as necessary, and give the cell range a name.

Right now I am just trying to pass the filename to excel to get it to open the file.

Below is the relevant code. The comment is the actual string. I have tested this by sending the code in the variable $excelExecute to notepad. The string looks correct and works if copy/pasted directly from notepad into the Run command. However, when I put the variable in the Run command, as below, nothing happens. What am I doing wrong?

$excelExecute = "'" & "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.exe " & """" & $fileName[0] & """" & "'"

;'C:\Program Files\Microsoft Office\OFFICE11\EXCEL.exe "O:\Check Sheets,logsheets\Blank Check Sheet.xls"'
Run($excelExecute)
Link to comment
Share on other sites

Hi,

use

ShellExecute ("excel.exe", $fileName[0])

You also should have a look at helpfile _excel* functions.

;-))

Stefan

Thanks!!! The ShellExecute did the trick. I don't think the _excel functions won't be of much help. These files are similar, but not all the same. I need to mark a certain area (which can be one cell, or several cells), merge the cells, then give them a name. From what I could tell, none of the built in AutoIt functions would do that. So basically, I am gonna open each file, highlight a given area, and have a sort of "AutoIt Toolbar" with several buttons that I can click that will do what I want. (It's the same stuff on every sheet, but in different locations on the sheet and sometimes formatted differently).
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...