HERBERS Excel-Forum - das Archiv
Datei Typ auswerten
Steffen

Hallo Excelfreunde
Ich habe ein Programm erstellt welches Excel CSV Dateien formatiert. Nun möchte ich gern eine Abfrage voran stellen, die prüft ob die zuformatierende Datei auch vom Typ csv ist. Ich habe es mit :
If ActiveSheet.Name Like "*.csv" Then
mein Makro
end if
...versucht ,funktioniert aber auch nur wenn der Dateiname logischerweise mit dieser Endung gespeichert wurde,was nicht immer der Fall ist.
Gibt es eine Möglichkeit die zuformatierende Datei auf Datei Typ zu Prüfen ?
Alle Recherchen im Internet brachten mich auch nicht weiter...
Viele Grüße
Steffen

AW: Datei Typ auswerten
Chris

Servus Steffen,
vllt. hilft dir das weiter:
Sub gh()
MsgBox Right(ActiveWorkbook.Name, InStr(1, StrReverse(ActiveWorkbook.Name), "."))
End Sub
spukt dir die Endung des aktiven Workbooks aus.
Gruß
Chris
If ActiveWorkbook.FileFormat=xlCSV then...'_oT
NoNet

_oT = "ohne Text"
xlFileFormat-Konstanten ausgeben
NoNet

Hey,
hier noch ein Nachtrag : Mit folgendem Makro kann man im VBA-Direktbereich die numerischen Werte der xlKonstanten der Eigenschaft "FileFormat" ausgeben, um diese mit dem Wert der aktuellen Mappe zu vergleichen :
Sub xlFileFormatAusgeben()
'Hier die xlKonstanten als Werte ausgeben :
Debug.Print "xlCSV : ", xlCSV
Debug.Print "xlCSVMSDOS : ", xlCSVMSDOS
Debug.Print "xlCurrentPlatformText : ", xlCurrentPlatformText
Debug.Print "xlDBF3 : ", xlDBF3
Debug.Print "xlDIF : ", xlDIF
Debug.Print "xlExcel2FarEast : ", xlExcel2FarEast
Debug.Print "xlExcel4 : ", xlExcel4
Debug.Print "xlAddIn : ", xlAddIn
Debug.Print "xlCSVMac : ", xlCSVMac
Debug.Print "xlCSVWindows : ", xlCSVWindows
Debug.Print "xlDBF2 : ", xlDBF2
Debug.Print "xlDBF4 : ", xlDBF4
Debug.Print "xlExcel2 : ", xlExcel2
Debug.Print "xlExcel3 : ", xlExcel3
Debug.Print "xlExcel4Workbook : ", xlExcel4Workbook
Debug.Print "xlExcel5 : ", xlExcel5
Debug.Print "xlExcel7 : ", xlExcel7
Debug.Print "xlExcel9795 : ", xlExcel9795
Debug.Print "xlHtml : ", xlHtml
Debug.Print "xlIntlAddIn : ", xlIntlAddIn
Debug.Print "xlIntlMacro : ", xlIntlMacro
Debug.Print "xlSYLK : ", xlSYLK
Debug.Print "xlTemplate : ", xlTemplate
Debug.Print "xlTextMac : ", xlTextMac
Debug.Print "xlTextMSDOS : ", xlTextMSDOS
Debug.Print "xlTextPrinter : ", xlTextPrinter
Debug.Print "xlTextWindows : ", xlTextWindows
Debug.Print "xlUnicodeText : ", xlUnicodeText
Debug.Print "xlWebArchive : ", xlWebArchive
Debug.Print "xlWJ2WD1 : ", xlWJ2WD1
Debug.Print "xlWJ3 : ", xlWJ3
Debug.Print "xlWJ3FJ3 : ", xlWJ3FJ3
Debug.Print "xlWK1 : ", xlWK1
Debug.Print "xlWK1ALL : ", xlWK1ALL
Debug.Print "xlWK1FMT : ", xlWK1FMT
Debug.Print "xlWK3 : ", xlWK3
Debug.Print "xlWK3FM3 : ", xlWK3FM3
Debug.Print "xlWK4 : ", xlWK4
Debug.Print "xlWKS : ", xlWKS
Debug.Print "xlWorkbookNormal : ", xlWorkbookNormal
Debug.Print "xlWorks2FarEast : ", xlWorks2FarEast
Debug.Print "xlWQ1 : ", xlWQ1
Debug.Print "xlXMLSpreadsheet : ", xlXMLSpreadsheet
'Hier das Format der aktuellen Mappe ausgeben :
Debug.Print ActiveWorkbook.FileFormat
End Sub
Gruß, NoNet
xlFileFormat-Konstanten ausgeben
NoNet

Hey,
hier noch ein Nachtrag : Mit folgendem Makro kann man im VBA-Direktbereich die numerischen Werte der xlKonstanten der Eigenschaft "FileFormat" ausgeben, um diese mit dem Wert der aktuellen Mappe zu vergleichen :
Sub xlFileFormatAusgeben()
'Hier die xlKonstanten als Werte ausgeben :
Debug.Print "xlCSV : ", xlCSV
Debug.Print "xlCSVMSDOS : ", xlCSVMSDOS
Debug.Print "xlCurrentPlatformText : ", xlCurrentPlatformText
Debug.Print "xlDBF3 : ", xlDBF3
Debug.Print "xlDIF : ", xlDIF
Debug.Print "xlExcel2FarEast : ", xlExcel2FarEast
Debug.Print "xlExcel4 : ", xlExcel4
Debug.Print "xlAddIn : ", xlAddIn
Debug.Print "xlCSVMac : ", xlCSVMac
Debug.Print "xlCSVWindows : ", xlCSVWindows
Debug.Print "xlDBF2 : ", xlDBF2
Debug.Print "xlDBF4 : ", xlDBF4
Debug.Print "xlExcel2 : ", xlExcel2
Debug.Print "xlExcel3 : ", xlExcel3
Debug.Print "xlExcel4Workbook : ", xlExcel4Workbook
Debug.Print "xlExcel5 : ", xlExcel5
Debug.Print "xlExcel7 : ", xlExcel7
Debug.Print "xlExcel9795 : ", xlExcel9795
Debug.Print "xlHtml : ", xlHtml
Debug.Print "xlIntlAddIn : ", xlIntlAddIn
Debug.Print "xlIntlMacro : ", xlIntlMacro
Debug.Print "xlSYLK : ", xlSYLK
Debug.Print "xlTemplate : ", xlTemplate
Debug.Print "xlTextMac : ", xlTextMac
Debug.Print "xlTextMSDOS : ", xlTextMSDOS
Debug.Print "xlTextPrinter : ", xlTextPrinter
Debug.Print "xlTextWindows : ", xlTextWindows
Debug.Print "xlUnicodeText : ", xlUnicodeText
Debug.Print "xlWebArchive : ", xlWebArchive
Debug.Print "xlWJ2WD1 : ", xlWJ2WD1
Debug.Print "xlWJ3 : ", xlWJ3
Debug.Print "xlWJ3FJ3 : ", xlWJ3FJ3
Debug.Print "xlWK1 : ", xlWK1
Debug.Print "xlWK1ALL : ", xlWK1ALL
Debug.Print "xlWK1FMT : ", xlWK1FMT
Debug.Print "xlWK3 : ", xlWK3
Debug.Print "xlWK3FM3 : ", xlWK3FM3
Debug.Print "xlWK4 : ", xlWK4
Debug.Print "xlWKS : ", xlWKS
Debug.Print "xlWorkbookNormal : ", xlWorkbookNormal
Debug.Print "xlWorks2FarEast : ", xlWorks2FarEast
Debug.Print "xlWQ1 : ", xlWQ1
Debug.Print "xlXMLSpreadsheet : ", xlXMLSpreadsheet
'Hier das Format der aktuellen Mappe ausgeben :
Debug.Print ActiveWorkbook.FileFormat
End Sub
Gruß, NoNet
Danke NoNet & Chris!
Steffen

@NoNet :Großartig! genau das hab ich gesucht!
Vielen Dank