der nachfolgende Code importiert, wenn ich das richtig verstehe, den Quelltext oder Websitetext des aktiven IE und speichert ihn in eine Textdatei. Wie muß ich den Code verändern, wenn ich den ...Text in Tabelle "Quelltext" der aktiven Mappe abspeichern möchte (das Tabellenblatt sollte dabei möglichst ausgeblendet sein)? - Danke schon jetzt für die Rückmeldungen.
Gruß - Wolfgang
Option Explicit
Sub Textimport()
Dim objShellWindows As New SHDocVw.ShellWindows
Dim objShellWindow As Object
On Error Resume Next
Dim lfCount As Integer, txtSearch As Long
Dim sTxt As String, txtLine As String, txtbool As Boolean
For Each objShellWindow In objShellWindows
If TypeName(objShellWindow.Document) = "HTMLDocument" Then
Do: Loop Until objShellWindow.Busy = False
Do: Loop Until objShellWindow.Busy = False
sTxt = objShellWindow.Document.DocumentElement.outerText 'oder outerHTML
Set objShellWindow = Nothing
Close
Open ThisWorkbook.Path & "\test.txt" For Output As #1
lfCount = 1
For txtSearch = 1 To Len(sTxt)
If txtbool Then
If Mid(sTxt, txtSearch, 1) = vbCr Then
Print #1, txtLine
txtLine = ""
txtbool = False
Else
txtLine = txtLine & Mid(sTxt, txtSearch, 1)
End If
Else
If Mid(sTxt, txtSearch, 1) = vbLf Then lfCount = lfCount + 1
Select Case lfCount
Case 0 To 25000: txtbool = True 'Zeile 20 bis 25000
End Select
End If
Next
Close
MsgBox "Der Text wurde gespeichert unter:" & vbLf & ThisWorkbook.Path & "\test.txt"
End If
Next objShellWindow
End Sub