Saber
Erfahrenes Mitglied
Hallo!
Folgendes Problem:
Ich greife mit Visual Basic auf MS-Word 97 zu. Ich versuche Daten aus VB in ein Word-Dokument mittels VBA zu schreiben. Das hat auch die ganze Zeit funktioniert, nur neuerdings bringt mir VB folgenden Fehler:
-2147417851 (80010105): Die Methode 'MoveDown' für das Objekt 'Selection' ist fehlgeschlagen
Ich habe keine Ahnung wieso. Hier ist der Source Code:
In der 9. Zeile (MSWordApp.Selection.MoveDown Unit:=wdLine, Count:=2) wirft er mir dann den Fehler. Fange ich in dieser Prozedur den Fehler mittels "On Error ..." ab, so tritt der Fehler automatisch bei der nächsten VBA-Zeile auf, die mit MS-Word zu tun hat.
*verzweifeltbin*
Hat jemand ´ne Ahnung, was man da machen könnte oder woran das liegt???
VIELEN DANK IM VORAUS!!!
MfG
Mike
Folgendes Problem:
Ich greife mit Visual Basic auf MS-Word 97 zu. Ich versuche Daten aus VB in ein Word-Dokument mittels VBA zu schreiben. Das hat auch die ganze Zeit funktioniert, nur neuerdings bringt mir VB folgenden Fehler:
-2147417851 (80010105): Die Methode 'MoveDown' für das Objekt 'Selection' ist fehlgeschlagen
Ich habe keine Ahnung wieso. Hier ist der Source Code:
Code:
Public Sub CreateHead(Komp As String, Head As Boolean)
'Head, Teil 1
If (Head = True) Then
'System "schlafen" lassen (MS-Word ist zu langsam! *fg* ;))
Sleep 500
MSWordApp.Selection.MoveRight Unit:=wdCharacter, Count:=8
MSWordApp.Selection.MoveDown Unit:=wdLine, Count:=2
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.Font.Bold = wdToggle
MSWordApp.Selection.Font.Name = "Courier New"
MSWordApp.Selection.Font.Size = 20
MSWordApp.Selection.TypeText Text:="STATUSBERICHT"
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.Font.Size = 10
MSWordApp.Selection.Font.Name = "Arial"
MSWordApp.Selection.Font.Bold = wdToggle
MSWordApp.Selection.TypeText Text:="generiert am "
MSWordApp.Selection.InsertDateTime DateTimeFormat:="tttt, t. MMMM jjjj", _
InsertAsField:=True
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.TypeParagraph
On Error GoTo 0
End If
'Head, Teil 2
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.Font.Name = "Courier New"
MSWordApp.Selection.Font.Size = 12
MSWordApp.Selection.Font.Bold = wdToggle
MSWordApp.Selection.TypeText Text:="Fehlerstatus (" + Komp + ")"
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.Font.Size = 8
MSWordApp.Selection.Font.Name = "Arial"
MSWordApp.Selection.Font.Bold = wdToggle
MSWordApp.Selection.TypeText Text:= _
"Wie viele Fehler gibt es pro Kategorie pro Kunde?"
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.TypeParagraph
MSWordApp.Selection.Font.Name = "Courier New"
MSWordApp.Selection.Font.Size = 10
End Sub
In der 9. Zeile (MSWordApp.Selection.MoveDown Unit:=wdLine, Count:=2) wirft er mir dann den Fehler. Fange ich in dieser Prozedur den Fehler mittels "On Error ..." ab, so tritt der Fehler automatisch bei der nächsten VBA-Zeile auf, die mit MS-Word zu tun hat.
*verzweifeltbin*

Hat jemand ´ne Ahnung, was man da machen könnte oder woran das liegt???
VIELEN DANK IM VORAUS!!!

MfG
Mike
Zuletzt bearbeitet: