|
Answer» First off, this is the first batch file I've ever made, so use dummy-speak around me
I'm trying to write a batch file for work, and I need it to open an excel file.
However, the exact file that needs to be opened varies, according to what day it is.
For EXAMPLE -
On January 1, 2008 I would want it to open up file 01012008.xls On March 23, 2005, I would want it to open up file 03232005.xls (Not the actual file names, but the same basic idea.)
I don't want to do anything with the file, I just want the batch to open it.
I'm not quite sure how to make the batch file automatically update to open up the PROPER file for the date it's being USED, or even if it's possible in a batch file.
If it helps, I'm also opening up Excel first, and then opening up the particular file, since I need separate windows for each, and the Excel PROGRAM at work tends to open up new books in the same program.
I'm not sure if this is enough information, I can give more if needed. Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("WScript.Shell") y=Year(Now) d=Day(Now) m=Month(Now) If Len(m) <= 1 Then m = "0" & m End If strFile = m & d & y & ".xls" If objFS.FileExists(strFile) Then Return = WshShell.Run("excel " & strFile, 1, true) End If save as script.vbs and on command line C:\test> cscript /nologo script.vbs
|