VBS Fehler
-
Hallo zusammen,
ich bin nicht gerade fit was VBS angeht und würde euch gerne um Rat fragen.
Ich habe ein kurzes VBS:Option Explicit Dim objExcel1, objWB, strPathExcel1 Set objExcel1 = CreateObject("Excel.Application") myPath = "C:\" WorkFile = Dir(myPath & "*.xls") Do While WorkFile <> "" If Right(WorkFile, 4) <> "xlsm" Then Set objWB = objExcel1.Workbooks.Open(myPath & WorkFile) objWB.SaveAs Filename:=myPath & WorkFile & "m" REM objWB.SaveAs(Filename:=myPath & WorkFile & "m",FileFormat:=XlFileFormat.xlWorkbookDefault,Password:=Nothing,WriteResPassword:=Nothing,ReadOnlyRecommended:=Nothing,CreateBackup:=Nothing,AccessMode:=XlSaveAsAccessMode.xlNoChange,ConflictResolution:=Nothing,AddToMru:=Nothing,TextCodepage:=Nothing,TextVisualLayout:=Nothing,Local:=Nothing) objWB.Close End If WorkFile = Dir() Loop objExcel1.Quit Set objWB = Nothing Set objExcel1 = Nothing
Was tut das Ding? Es geht einfach alle Excel Files in einem Verzeichnis durch, öffnet jede Excel File und speichert sie mit einem anderen Format. Soweit so gut. Ich bekomme jetzt nur beim SaveAs ständig Fehlermeldungen wie "Anweisung erwartet" und wenn ich es mit Klammern schreibe ") erwartet".
Der Code wird NICHT in einem Excel Macro ausgeführt sondern aus einer seperaten VBS File. Was mache ich falsch?
-
Filename:=myPath
Was soll das sein? Ich kann zwar kaum VBS, aber es würde mich irgendwie überraschen, wenn das gültige VBS Syntax wäre.