#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default VB Script

Hello. I would like to schedule a VB Script to run (via Windows Scheduler),
which will simply copy a file from one directory into another with the name
of the copied file as as a today timestamp. I am extremely new to VB
Script - can anyone help with the syntax? Thank you.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default VB Script

This may help. Here is a VB script I use to copy my XLB backup files over
the current XLBs. This goes in a VBS file as you know.


dim FSO
dim Path

Path = "C:\Documents and Settings\jarech\Application Data\Microsoft\Excel\"
Set FSO = CreateObject("Scripting.FileSystemObject")

FSO.CopyFile Path & "Excel11Bak.xlb", Path & "Excel11.xlb"
FSO.CopyFile Path & "Excel10Bak.xlb", Path & "Excel10.xlb"
FSO.CopyFile Path & "ExcelBak.xlb", Path & "Excel.xlb"

--
Jim
"Steph" wrote in message
...
| Hello. I would like to schedule a VB Script to run (via Windows
Scheduler),
| which will simply copy a file from one directory into another with the
name
| of the copied file as as a today timestamp. I am extremely new to VB
| Script - can anyone help with the syntax? Thank you.
|
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default VB Script

Thanks Jim. It worked perfectly. But I messed it up a bit by trying to
have the copied file named as today's timestamp:

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile sExcelPath, CopytoPath & Format(Now, "yyyymmddhhmmss") & ".xls"

When I ran, I got an error: Variable is undefined: 'Format'
So I'm guessing I am mixing VBA with VBS. Any idea how I would rewrite this
in VBS syntax? Thanks!




"Jim Rech" wrote in message
...
This may help. Here is a VB script I use to copy my XLB backup files over
the current XLBs. This goes in a VBS file as you know.


dim FSO
dim Path

Path = "C:\Documents and Settings\jarech\Application

Data\Microsoft\Excel\"
Set FSO = CreateObject("Scripting.FileSystemObject")

FSO.CopyFile Path & "Excel11Bak.xlb", Path & "Excel11.xlb"
FSO.CopyFile Path & "Excel10Bak.xlb", Path & "Excel10.xlb"
FSO.CopyFile Path & "ExcelBak.xlb", Path & "Excel.xlb"

--
Jim
"Steph" wrote in message
...
| Hello. I would like to schedule a VB Script to run (via Windows
Scheduler),
| which will simply copy a file from one directory into another with the
name
| of the copied file as as a today timestamp. I am extremely new to VB
| Script - can anyone help with the syntax? Thank you.
|
|
|




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default VB Script

Got it:

CStr(Year(Now)) & Right(00 & CStr(Month(Now)),2) & Right(00 &
CStr(Day(Now)),2) & Right(00 & CStr(Hour(Now)),2) & Right(00 &
CStr(Minute(Now)),2) & Right(00 & CStr(Second(Now)),2)

Format doesn't exist in VBS, so build your own!!

"Steph" wrote in message
...
Thanks Jim. It worked perfectly. But I messed it up a bit by trying to
have the copied file named as today's timestamp:

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile sExcelPath, CopytoPath & Format(Now, "yyyymmddhhmmss") &

".xls"

When I ran, I got an error: Variable is undefined: 'Format'
So I'm guessing I am mixing VBA with VBS. Any idea how I would rewrite

this
in VBS syntax? Thanks!




"Jim Rech" wrote in message
...
This may help. Here is a VB script I use to copy my XLB backup files

over
the current XLBs. This goes in a VBS file as you know.


dim FSO
dim Path

Path = "C:\Documents and Settings\jarech\Application

Data\Microsoft\Excel\"
Set FSO = CreateObject("Scripting.FileSystemObject")

FSO.CopyFile Path & "Excel11Bak.xlb", Path & "Excel11.xlb"
FSO.CopyFile Path & "Excel10Bak.xlb", Path & "Excel10.xlb"
FSO.CopyFile Path & "ExcelBak.xlb", Path & "Excel.xlb"

--
Jim
"Steph" wrote in message
...
| Hello. I would like to schedule a VB Script to run (via Windows
Scheduler),
| which will simply copy a file from one directory into another with the
name
| of the copied file as as a today timestamp. I am extremely new to VB
| Script - can anyone help with the syntax? Thank you.
|
|
|






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need some VB script please rlee1999 Excel Discussion (Misc queries) 2 October 25th 06 05:46 PM
VB script help - please!! Anthony Excel Discussion (Misc queries) 1 July 13th 05 01:19 AM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
Script? Scrappy[_2_] Excel Programming 1 July 21st 03 08:44 PM
what is a vb script george Excel Programming 1 July 16th 03 09:56 AM


All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"