Jump to content

Recommended Posts

Posted

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)
Posted (edited)

Hi,

use

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

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

;-))

Stefan

Edited by 99ojo
Posted

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

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
×
×
  • Create New...