AW: Tut mir leid....
01.03.2010 08:44:36
Reinhard
Hallo Rainer,
okay, ich habe eine ähnlich große csv. So 130.000 Zeilen, 24 MB.
Scheinbar ist Notepad schneller als Vba-Open beim Einlesen.
Ca. 10 sec und Notepad ist weg und Alles und A() sind befüllt.
Die untere Prozedur fand ich bei Hans, ich komme damit nicht so klar. Aber geht ja auch ohne.
Option Explicit
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const WAIT_TIMEOUT = &H102&
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAcess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Sub Einlesen()
' Verweis auf MS Forms 2.0 muß gesetzt sein wegen Dataobject
Dim A() As String, Alles$, MyData As New DataObject, Zei As Long, Anz As Integer, NP
On Error GoTo Hell
Application.ScreenUpdating = False
Application.SendKeys "^a^c%db"
NP = Shell("NotePad.exe c:\test\sehrgross.csv", vbMaximizedFocus)
MyData.GetFromClipboard
Alles = MyData.GetText(1)
'Application.SendKeys "%db"
'Call WartenBisFertig
A = Split(Alles, Chr(10))
'DoEvents
MsgBox Len(Alles)
MsgBox UBound(A)
Hell:
Application.ScreenUpdating = True
End Sub
Sub WartenBisFertig()
Dim ProcessID As Long, hProcess As Long, RetVal As Long
ProcessID = Shell("NotePad.exe c:\test\sehrgross.csv", vbNormalNoFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
Do
DoEvents
RetVal = WaitForSingleObject(hProcess, 50)
Loop Until RetVal WAIT_TIMEOUT
End Sub
Gruß
Reinhard