I'm using excel 2002, from the office xp suite
The name of the excel file is :
10-05-03_Hookston_3480_Sunday.xls
but it changes on a daily basis
The names of the imported files are:
001.txt
003.txt
256.txt
These file names never change, and cannot be changed.
The macro that is run does the following:
Opens a Hookston Template (Hookston_3480_Template.xls)
Saves the Hookston Template with whatever the date is in the file name
(10-05-03_Hookston_3480_Sunday.xls,
10-10-03_Hookston_3480_Friday.xls, etc)
Closes the workbook and excel.
The importing of the files is all done by excel, it was setup by doing
the following:
From an excel workbook
Click Data
Click Import External Data
Click Import Data
Select file you wish to import
-If it's a txt file it will ask about delimiting and all that so that it
is formated correctly
Click Finish
If you then write click on the data and go to
External Data Range Properties, one of the options is
Refresh Data on file open.
When we realized that by opening the files after there creation date was
changing the files, the first thing I did was try to get to the External
Data Range Properites using VBA, but could not find any commands that
let me alter those properties. After hearing some of the responses I
changed the opening macro, it now does the following:
Opens a Hookston Template (Hookston_3480_Template.xls)
Cycles through all data sheets and protects them.
(I found that if I protect the whole workbook at once, the text files
are still imported)
Saves the Hookston Template with whatever the date is in the file name
(10-05-03_Hookston_3480_Sunday.xls,
10-10-03_Hookston_3480_Friday.xls, etc)
Closes the workbook and excel.
This would be fine if the only time the after the workbook is created it
was done by a person looking for something, but it is not. Every couple
of days another macro is ran, it does the following:
Opens up 10-05-03_Hookston_3480_Sunday.xls (or whatever day)
Cycles through all Charts Sheets in the workbook
Prints out Charts
Closes workbook, Closes excel
So the original problem we were having is that when the workbook was
opened to print out a previous days charts, the data was changed, and
incorrect charts were printed. Now with the protection when the data
goes to update and error message pops up saying that "The sheet is
protected, so the data won't update, do you want to continue?"
This message requires someone to click continue, then the macro
completes, printing out the charts and closing excel.
This process needs to have no human intervention.