Saving open file and opening new file at a specified time of day 
Author Message
 Saving open file and opening new file at a specified time of day

Hi,

This is all pretty new to me, but I was wondering how difficult it is
to do this:
I start with an open spreadsheet "Excel_01_07_02.xls".
At 12 midnight,I'd like to close that file and open a new one,
"Excel_01_02_08.xls".

Is this possible ?

The name of the file doesn't matter too much, I was just thinking of
matching the name to the date for ease of sorting.

Thanks for your help,

Jim



Sat, 26 Jun 2004 23:34:11 GMT  
 Saving open file and opening new file at a specified time of day
Run something like the following script:
---8<--------------------------------------------------
Set objXL = CreateObject("Excel.Application")

Datum = Date()

' The main loop
Do
  FName = OpenFile()
  While Datum = Date()
    ' Sleep for one second
    Wscript.Sleep 1000
  Wend
  CloseFile(FName)
Loop While True

Function OpenFile()
  Set objWorkBook = objXL.Workbooks.Add
  objXL.DisplayAlerts = False
  objWorkBook.Activate
  objWorkBook.SaveAs "test" & Date()

  objXL.Application.Visible = True
  objXL.DisplayAlerts = True
  'Work here

  OpenFile = "test" & Date()
End Function

Sub CloseFile()
  objXL.WorkBooks(FName).Close
End Sub
---8<--------------------------------------------------


Quote:
> Hi,

> This is all pretty new to me, but I was wondering how difficult it is
> to do this:
> I start with an open spreadsheet "Excel_01_07_02.xls".
> At 12 midnight,I'd like to close that file and open a new one,
> "Excel_01_02_08.xls".

> Is this possible ?

> The name of the file doesn't matter too much, I was just thinking of
> matching the name to the date for ease of sorting.

> Thanks for your help,

> Jim



Sun, 27 Jun 2004 22:26:17 GMT  
 Saving open file and opening new file at a specified time of day
Ooops...
Of course the Datum = Date() line should be inside the Do loop, otherwise it
would be a lot of open workbooks at 0:00 :)))

Mike


Quote:
> Run something like the following script:
> ---8<--------------------------------------------------
> Set objXL = CreateObject("Excel.Application")

> Datum = Date()

> ' The main loop
> Do
>   FName = OpenFile()
>   While Datum = Date()
>     ' Sleep for one second
>     Wscript.Sleep 1000
>   Wend
>   CloseFile(FName)
> Loop While True

> Function OpenFile()
>   Set objWorkBook = objXL.Workbooks.Add
>   objXL.DisplayAlerts = False
>   objWorkBook.Activate
>   objWorkBook.SaveAs "test" & Date()

>   objXL.Application.Visible = True
>   objXL.DisplayAlerts = True
>   'Work here

>   OpenFile = "test" & Date()
> End Function

> Sub CloseFile()
>   objXL.WorkBooks(FName).Close
> End Sub
> ---8<--------------------------------------------------



> > Hi,

> > This is all pretty new to me, but I was wondering how difficult it is
> > to do this:
> > I start with an open spreadsheet "Excel_01_07_02.xls".
> > At 12 midnight,I'd like to close that file and open a new one,
> > "Excel_01_02_08.xls".

> > Is this possible ?

> > The name of the file doesn't matter too much, I was just thinking of
> > matching the name to the date for ease of sorting.

> > Thanks for your help,

> > Jim



Sun, 27 Jun 2004 22:54:35 GMT  
 Saving open file and opening new file at a specified time of day
Cool. Thanks..

On Wed, 9 Jan 2002 15:54:35 +0100, "Mike Musterd"

Quote:

>Ooops...
>Of course the Datum = Date() line should be inside the Do loop, otherwise it
>would be a lot of open workbooks at 0:00 :)))

>Mike



>> Run something like the following script:
>> ---8<--------------------------------------------------
>> Set objXL = CreateObject("Excel.Application")

>> Datum = Date()

>> ' The main loop
>> Do
>>   FName = OpenFile()
>>   While Datum = Date()
>>     ' Sleep for one second
>>     Wscript.Sleep 1000
>>   Wend
>>   CloseFile(FName)
>> Loop While True

>> Function OpenFile()
>>   Set objWorkBook = objXL.Workbooks.Add
>>   objXL.DisplayAlerts = False
>>   objWorkBook.Activate
>>   objWorkBook.SaveAs "test" & Date()

>>   objXL.Application.Visible = True
>>   objXL.DisplayAlerts = True
>>   'Work here

>>   OpenFile = "test" & Date()
>> End Function

>> Sub CloseFile()
>>   objXL.WorkBooks(FName).Close
>> End Sub
>> ---8<--------------------------------------------------



>> > Hi,

>> > This is all pretty new to me, but I was wondering how difficult it is
>> > to do this:
>> > I start with an open spreadsheet "Excel_01_07_02.xls".
>> > At 12 midnight,I'd like to close that file and open a new one,
>> > "Excel_01_02_08.xls".

>> > Is this possible ?

>> > The name of the file doesn't matter too much, I was just thinking of
>> > matching the name to the date for ease of sorting.

>> > Thanks for your help,

>> > Jim

Jim Snodgrass
S and S Communications
AT&T/Lucent/Avaya Product Specialists
315-626-3289 Office
315-415-7115 Cell

"You cannot escape the responsibility of tomorrow by evading it today."
-Abraham Lincoln



Mon, 28 Jun 2004 09:26:10 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. opening / saving files with MS rich text box control (viewing open files)

2. Specifying JScript Open() to alwats open new browser.

3. File types, and open specified file type

4. Open As or Save As an Access Database file under a new name

5. saving a file at specified time intervals

6. Opening a File Open window for file selection in VBA

7. Getting open file name w/o opening file

8. Replacing the File Open/File Save As box?

9. File Creation Date/Time of an open file

10. Can't Specify Field Delimiter When Opening Recordset on a Text File

11. question on opening a file with specified Fonts

12. Opening files with a specified program, from code?

 

 
Powered by phpBB® Forum Software