Makro ausführen.....
27.12.2003 21:12:55
Chris
ich möchte gerne eine Tabelle die sich in einer Arbeitsmappe befindet beim Beenden von Excel automatisch in eine .txt oder .cvs exportieren. Sobald ich jetzt meine Arbeitsmappe wieder starte soll die Tabelle automatische importiert werden.
Die Makros habe ich schon:
Sub AlsTextSpeichern()
Dim TB As Worksheet, Dateinummer%
Dim z%, s%, TMP$
exportfile = "C:\Pfad\Daten"
Dateinummer = FreeFile
Set TB = ThisWorkbook.Worksheets(1)
Open exportfile For Output As #Dateinummer
For z = 1 To TB.UsedRange.Rows.Count
If Cells(z, 2).Value = Text Then SL = 10 Else SL = 6
For s = 1 To TB.UsedRange.Columns.Count
TMP = TMP & CStr(TB.Cells(z, s).Text) & ";"
Next s
TMP = Left(TMP, Len(TMP) - 1)
Print #Dateinummer, TMP
TMP = ""
Next z
Close #Dateinummer
End Sub
Sub TextImport()
Dim intRow As Integer, intCol As Integer
Dim strTxt As String
Close
Open "C:\Pfad\Daten" For Input As #1
Do Until EOF(1)
intRow = intRow + 1
Input #1, strTxt
strTxt = Application.Trim(strTxt)
strTxt = Application.Clean(strTxt)
Do Until InStr(strTxt, ";") = 0
intCol = intCol + 1
Cells(intRow, intCol) = Left(strTxt, InStr(strTxt, ";") - 1)
strTxt = Right(strTxt, Len(strTxt) - InStr(strTxt, ";"))
Loop
intCol = intCol + 1
Cells(intRow, intCol) = strTxt
intCol = 0
Loop
Close
End Sub
Das Problem ist allerding, wie bekomme ich es hin, dass
Sub AlsTextSpeichern() beim verlassen und
Sub TextImport() beim öffnen der Arbeitsmappe ausgeführt wird ????
Danke und Gruss
Chris
Anzeige