per batchdatei mehrere Datein öffnen

  • #1
J

joergi78

Bekanntes Mitglied
Themenersteller
Dabei seit
17.08.2005
Beiträge
249
Reaktionspunkte
0
Hallöchen an alle,
ich möchte eine Batchdatei schreiben, mit der ich auf einmal alle Dateien imOrdner mit einem Klick öffnen kann.
Es handelt sich um Excel Dateien.
*.xls und *.xlt
Hoffe ihr könnt mir helfen

*verschoben von Windows XP*
 
  • #2
sind das immer die gleich oder soll es auch noch funktionieren wenn mal eine neue datei in den ordner kommt?
 
  • #3
Hallo.


Am einfachsten ist es in Excel selber ueber das Menue (Datei oeffnen) alle Dateien auszuwaehlen die du oeffnen willst. Nachdem Oeffnen erscheint fuer jede Datei jeweils n eigenes Excel-Fenster.
 
  • #4
mr.ant schrieb:
sind das immer die gleich oder soll es auch noch funktionieren wenn mal eine neue datei in den ordner kommt?
es sind jeden Monat neue Dateien. Es soll also auch funktionieren, wenn neue Dateien dazukommen. Es sind aber immer xls. Datein.
 
  • #5
Hallo,

eine Batch-Datei habe ich nicht für dich, aber ich glaube das folgende VBS-Script ist das, was du brauchst...

Code:
Option Explicit

' File-Attributes enum...
Const Attrib_Normal     = 0
Const Attrib_ReadOnly   = 1
Const Attrib_Hidden     = 2
Const Attrib_System     = 4
Const Attrib_Volume     = 8
Const Attrib_Directory  = 16
Const Attrib_Archive    = 32
Const Attrib_Alias      = 1024
Const Attrib_Compressed = 2048

Dim objExcelApp
Dim objExcelWb
Dim objFSO
Dim objFolder
Dim objFile

On Error Resume Next
' Open Excel...
Set objExcelApp = WScript.CreateObject(Excel.Application)
If CheckError(err) Then
 WScript.Quit(12)
End If
' Open FSO...
Set objFSO = WScript.CreateObject(Scripting.FileSystemObject)
If CheckError(err) Then
 WScript.Quit(12)
End If
' iterate thru directory and open the workbooks...
Set objFolder = objFSO.GetFolder(f:\sheets)
If CheckError(err) Then
 WScript.Quit(12)
End If
For Each objFile In objFolder.Files
 If (LCase(objFSO.GetExtensionName(objFile.Path)) = xls) Or _
    (LCase(objFSO.GetExtensionName(objFile.Path)) = xlt) Then
  Set objExcelWb = objExcelApp.Workbooks.Open(objFile.Path)
  If CheckError(err) Then
   WScript.Quit(16)
  End If	 
 End If
Next 
' Show excel-window...
objExcelApp.Visible = True
Set objFolder = Nothing
Set objFSO    = Nothing
WScript.Quit(0)
' End of program...
' -------------------------------------------------------------------------------------------
' Helper-Function
Function CheckError(objError)
If objError.number <> 0 Then
 Call MsgBox(WScript.ScriptName & : Error, 0x & Hex(objError.number) &_
              occured,  & objError.Description)
 CheckError = True
 Exit Function
End If
CheckError = False
End Function
' -------------------------------------------------------------------------------------------

Gruss

Reiner
 
Thema:

per batchdatei mehrere Datein öffnen

ANGEBOTE & SPONSOREN

Statistik des Forums

Themen
113.838
Beiträge
707.959
Mitglieder
51.491
Neuestes Mitglied
haraldmuc
Oben