Laufzeitfehler 462, Der Remote-Server-Computer existiert nicht oder ist nicht verfügbar
Fehlermeldung beim 2. mal öffen einer Vorlage eines Word Dokumentes das über Makro aus einem mit VB6 Programmierten Programm ausgefüllt wird.
Hallo zusammen,
hab folgendes Problem,
und zwar hab ich zwar in VB6 einige Erfahrung, habe aber leider in VBA Programmierung, speziell bei einem Zugriff auf Word / Excel absolut keine erfahrung. Habe zwar schon seit 2 tagen bei google gesucht. Weiß jetzt zwar das die Fehlermeldung warscheinlich damit zusammenhängt, dass ich das Word irgendwie nicht richtig schließe. Daher das ich dort aber ein Grünschnabel bin benötige ich eure hilfe, weil ich zu keinem grünen Zweig komme. Hier meinen Programmtext: Und zwar greife ich auf ein Programm das ich mit VB6 Programmiere auf ein Word Dokument zu, der so lautet:
Private Sub cmdTestRechnungdruck_Click()
Dim word As New word.Application
Dim sBuffer As String
word.Documents.Add
word.Visible = True
sBuffer = "C:\Temp\"
ChangeFileOpenDirectory sBuffer
Documents.Open FileName:="Rechnung.doc", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
With word.ActiveWindow
.Selection.MoveDown
.Selection.MoveDown
.Selection.TypeParagraph
.Selection.TypeText Text:="Firma"
.Selection.MoveDown
.Selection.TypeText Text:="Name"
.Selection.TypeParagraph
.Selection.TypeText Text:="Straße"
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText Text:="Adresse"
.Selection.MoveDown
.Selection.MoveDown
.Selection.TypeParagraph
Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend
.Selection.TypeText Text:="Ort"
.Selection.TypeText Text:=", den "
.Selection.TypeText Text:=Date
.Selection.MoveDown unit:=wdLine, Count:=8
.Selection.TypeText Text:="Rechnungsnummer"
.Selection.MoveRight unit:=wdWord, Count:=3
.Selection.TypeText Text:=" "
.Selection.TypeText Text:="Kundennummer"
.Selection.MoveDown unit:=wdLine, Count:=3
.Selection.MoveLeft unit:=wdWord, Count:=4
.Selection.TypeText Text:="Position1"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung1"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl1"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis1"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis1"
.Selection.MoveDown
.Selection.MoveLeft unit:=wdWord, Count:=4
.Selection.TypeText Text:="Position2"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung2"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl2"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis2"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis2"
.Selection.MoveRight
.Selection.TypeText Text:="Position3"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung3"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl3"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis3"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis3"
.Selection.MoveDown
.Selection.TypeText Text:="Gesamtrechnungsbetrag"
.PrintOut
word.ActiveDocument.Saved = True
word.Documents.Close
ChangeFileOpenDirectory sBuffer
word.Application.Quit
End With
End Sub
Wie muss ich das Deklarieren das ich das Word Dokument auch ein zweites mal öffnen kann, ohne das dort die Fehlermeldung auftaucht?
Wo muss ich das Einfügen?
Muss ich irgendwelche Variablen anders Deklarieren??
Schonmal vielen Dank für eure Hilfe.
Gruß Sani03
hab folgendes Problem,
und zwar hab ich zwar in VB6 einige Erfahrung, habe aber leider in VBA Programmierung, speziell bei einem Zugriff auf Word / Excel absolut keine erfahrung. Habe zwar schon seit 2 tagen bei google gesucht. Weiß jetzt zwar das die Fehlermeldung warscheinlich damit zusammenhängt, dass ich das Word irgendwie nicht richtig schließe. Daher das ich dort aber ein Grünschnabel bin benötige ich eure hilfe, weil ich zu keinem grünen Zweig komme. Hier meinen Programmtext: Und zwar greife ich auf ein Programm das ich mit VB6 Programmiere auf ein Word Dokument zu, der so lautet:
Private Sub cmdTestRechnungdruck_Click()
Dim word As New word.Application
Dim sBuffer As String
word.Documents.Add
word.Visible = True
sBuffer = "C:\Temp\"
ChangeFileOpenDirectory sBuffer
Documents.Open FileName:="Rechnung.doc", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
With word.ActiveWindow
.Selection.MoveDown
.Selection.MoveDown
.Selection.TypeParagraph
.Selection.TypeText Text:="Firma"
.Selection.MoveDown
.Selection.TypeText Text:="Name"
.Selection.TypeParagraph
.Selection.TypeText Text:="Straße"
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText Text:="Adresse"
.Selection.MoveDown
.Selection.MoveDown
.Selection.TypeParagraph
Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend
.Selection.TypeText Text:="Ort"
.Selection.TypeText Text:=", den "
.Selection.TypeText Text:=Date
.Selection.MoveDown unit:=wdLine, Count:=8
.Selection.TypeText Text:="Rechnungsnummer"
.Selection.MoveRight unit:=wdWord, Count:=3
.Selection.TypeText Text:=" "
.Selection.TypeText Text:="Kundennummer"
.Selection.MoveDown unit:=wdLine, Count:=3
.Selection.MoveLeft unit:=wdWord, Count:=4
.Selection.TypeText Text:="Position1"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung1"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl1"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis1"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis1"
.Selection.MoveDown
.Selection.MoveLeft unit:=wdWord, Count:=4
.Selection.TypeText Text:="Position2"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung2"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl2"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis2"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis2"
.Selection.MoveRight
.Selection.TypeText Text:="Position3"
.Selection.MoveRight
.Selection.TypeText Text:="Leistung3"
.Selection.MoveRight
.Selection.TypeText Text:="Anzahl3"
.Selection.MoveRight
.Selection.TypeText Text:="Einzelpreis3"
.Selection.MoveRight
.Selection.TypeText Text:="Gesamtpreis3"
.Selection.MoveDown
.Selection.TypeText Text:="Gesamtrechnungsbetrag"
.PrintOut
word.ActiveDocument.Saved = True
word.Documents.Close
ChangeFileOpenDirectory sBuffer
word.Application.Quit
End With
End Sub
Wie muss ich das Deklarieren das ich das Word Dokument auch ein zweites mal öffnen kann, ohne das dort die Fehlermeldung auftaucht?
Wo muss ich das Einfügen?
Muss ich irgendwelche Variablen anders Deklarieren??
Schonmal vielen Dank für eure Hilfe.
Gruß Sani03
Please also mark the comments that contributed to the solution of the article
Content-Key: 80105
Url: https://administrator.de/contentid/80105
Printed on: April 18, 2024 at 04:04 o'clock
2 Comments
Latest comment
Dim word As New word.Application
Dim sBuffer As String
word.Documents.Add
word.Visible = True
diesen Teil verstehe ich nicht ganz. Das sollte doch eigentlich so aussehen
DIM word as OBJECT
Pivate sub test()
if word is nothing then
set word = Createobject("Word.Document.xxx)'xxx steht für die Wordversion
end if
with word.application
.visible = true
.
.
.
end with
AppActivate "Microsoft Word"
Clipboard.clear
word.activeDocument.close wdDoNotSaveChanges
end sub
Gruß
Sven