Domino 9 und frühere Versionen > Entwicklung
Object Variable not set
JM:
Hallo habe versucht mit folgendem Script ein Document in eine andere Datenbank (Feld für Feld) zu übertragen ... leider funzt das ganze nicht so
Fehlermldung: Object Variable not set.
Hat jemand ne idee???
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim oldDoc As NotesDocument
Dim newDoc As NotesDocument
Set db = s.GetDatabase("","TestMigrationZiel.nsf")
Set oldDoc = ws.CurrentDocument.Document
Set newdoc.Link = olddoc.Link
Set newdoc.DisplayChapter = olddoc.DisplayChapter
Set newdoc.DisplaySectionsandSubtitles = olddoc.DisplaySectionsandSubtitles
Set newdoc.DisplayDocumentVersion = olddoc.DisplayDocumentVersion
Set newdoc.Form = olddoc.Form
Set newdoc.ComposedDate = olddoc.ComposedDate
Set newdoc.Keythought = olddoc.Keythought
Set newDoc.Body = oldDoc.body
Set newdoc.NewsLetterSubject = olddoc.NewsLetterSubject
Set newdoc.DocAuthor = olddoc.DocAuthor
Set newdoc.DocReaders = olddoc.DocReaders
Set newdoc.Duid = olddoc.Duid
Set newdoc.set = olddoc.set
End Sub
Axel:
Hi,
die Fehlermeldung kommt mit Sicherheit von der Variable newdoc.
Du musst in der Zieldatenbank erstmal ein Document erstellen.
Füge diese Zeile
Set newdoc = New NotesDocument(db)
nach der Zeile
Set olddoc = ...
ein.
Dann sollte es funktionieren.
Axel
Axel:
Hi,
hier noch eine einfachere Alternative:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim oldDoc As NotesDocument
Dim newDoc As NotesDocument
Set db = s.GetDatabase("","TestMigrationZiel.nsf")
Set oldDoc = ws.CurrentDocument.Document
Set newdoc = New NotesDocument(db)
Call oldDoc.CopyAllItems(newdoc)
Call newdoc.Save(True, True) 'neues Dokument speichern
End Sub
Damit kopierst du alle Felder mit einem Schlag.
Axel
harkpabst_meliantrop:
Viel besser so, denn in seinem ersten Script fehlte so nebenbei bei allen Quellfeldern das "(0)". Nommaal.
--E<:|
JM:
danke axel
habe die zweite version getestet und diese funktioniert wunderbar
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln