Moin, ich habe deine code in meiner Subroutine hinzugefügt. aber es funktioniert nicht ...
Option Explicit
Public Sub test()
Dim DatNR As Long
Dim Dateiname As String
Dim inhalt As String
Dim astrTemp() As String, astrOutput() As String
Dim strInhalt As String
Dim ialngIndex As Long, lngColumn As Long, lngRow As Long
DatNR = FreeFile
Dateiname = "C:\Users\Desktop\vba\test.txt" 'hier den Pfad zur Datei eintragen bspw. C:\test.txt
Open Dateiname For Input As DatNR
inhalt = Input(LOF(DatNR), DatNR)
Close DatNR
'jetzt zurechtstutzen
inhalt = Trim(Split(inhalt, "Node")(1))
If InStr(1, inhalt, "*Extra", vbTextCompare) > 1 Then
inhalt = Trim(Split(inhalt, "*Extra")(0))
End If
inhalt = Replace(inhalt, ",", "")
inhalt = Replace(inhalt, ". ", " ")
MsgBox inhalt
' put inhalt to sheet
Application.ScreenUpdating = False
strInhalt = Sheet3.TextBox1.inhalt '//hier Dein Einlestext...
astrTemp = Split(Expression:=strInhalt, Delimiter:=vbCrLf)
For ialngIndex = 0 To UBound(astrTemp) Step 2
lngRow = lngRow + 1
astrOutput = Split(Expression:=astrTemp(ialngIndex), Delimiter:=" ")
Cells(lngRow, 1).Resize(1, UBound(astrOutput) + 1).Value = astrOutput()
Next
With Cells(1, 1).Resize(ialngIndex, UBound(astrOutput) + 1)
For lngColumn = 1 To .Columns.Count
With .Columns(lngColumn)
Call .TextToColumns(Destination:=.Cells(1, 1), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True)
End With
Next
End With
Application.ScreenUpdating = True
End Sub
Test.txt Inhalt:
*Heading
** Job name: Job1104 Model name: Model-1
** Generated by: Abaqus/CAE Student Edition 6.14-2
*Preprint, echo=NO, model=NO, history=NO, contact=NO
**
** PARTS
**
*Part, name=Part-1
*Node
1, 0., 0., 0.100000001
2, 41.6267433, 0., 0.100000001
3, 36.5496292, 23.4185276, 0.100000001
Gruß
|