Domino 9 und frühere Versionen > Entwicklung
Wordexport
MartinG:
Für die meisten hier sicherlich lächerlich. Leider habe ich von Lotus Script keine Ahnung. Ich habe unten stehendes Script in der Sandbox gefunden um Daten nach Word zu exportieren. Ich habe dieses Script in eine Aktion in meiner Maske eingebunden und das Script läuft auch korrekt ab.
Was ich jetzt aber nicht hinbekomme ist die fest vorgegebenen Werte durch Felder aus meinem Dokument zu ersetzen. Ich habe mal im Abschnitt:
'Predefined values: (replace with field values from uidoc)
orderid = "2183763248"
folgendes versucht was aber nicht funktioniert
orderid = fd_anfragenr
Leider habe ich von uidoc etc keine Ahnung? Wäre superklasse wenn mir hier jemand helfen könnte...
-----------------------------
Here is the code for creating a new Word document with form fields and updating the form fields with predefined values.
If you are in a UIDcument it is very easy to substitue the predefined values with variables/fields from the UIDocument
Dim s As New notessession
'Dim todaydate As New notesdatetime("Today")
Dim word As Variant
Dim wordoc As Variant
Dim todaysdate As String
Dim orderid As String
Dim producedby As String
Dim storeid As String
Dim customername As String
Dim address As String
Dim citytown As String
Dim postcode As String
Dim daytimeno As String
Dim eveningno As String
'Predefined values: (replace with field values from uidoc)
'todaysdate = todaydate.localtime
orderid = "2183763248"
producedby = s.username
storeid = "12345"
customername = "John Doe"
address = "Apartment 5c, 5 Test Avenue"
citytown = "Testtown"
postcode = "XX5 5XX"
daytimeno = "1234567890"
eveningno = "0987654321"
'Create the Word object:
Set word = CreateObject("Word.Application") 'Create Word object
Call word.documents.add("Return and Uplift.dot") 'Create a new document based on the template "Return and Uplift.Dot"
Set worddoc = word.activedocument 'Get a handle for the active document
'Assign the field values:
worddoc.FormFields(1).result = todaysdate
worddoc.FormFields(2).result = orderid
worddoc.FormFields(3).result = producedby
worddoc.FormFields(4).result = storeid
worddoc.FormFields(5).result = customername
worddoc.FormFields(6).result = address
worddoc.FormFields(7).result = citytown
worddoc.FormFields(8).result = postcode
worddoc.FormFields(9).result = daytimeno
worddoc.FormFields(10).result = eveningno
worddoc.saveas(customername) 'save the document with the filename of "John Doe.doc"
word.visible = True 'Comment this line if you don't want to show Word.
'word.quit 'remove comment if you want to close rather than show Word.
Don Pasquale:
Hi Martin_Georg,
um dein problem zu lösen fehlt noch ein Hinweis:
Hast Du das Document im Frontend, d.h. ist die
Maske gerade offen, oder hast Du es im Backend, d.h. schaust Du auf das Document aus einer View/Ansicht.
nebenbei :
ich empfehle Dir da mal die Homepage von ata
http://www.anton-tauscher.de/LotusScript/startdyn.htm
der hat eine Super einfürhung für LotussScript
Ciao
Don Pasquale
ata:
... von wo aus agierst du denn, wo hast du den Code eingefügt?
ata
MartinG:
Der Code ist in einer Aktion in einer Maske drin.
Ich habe mir das so gedacht das ich ganz normal ein neues Dokument erstelle und nach dem speichern des Dokuments noch die AKtion betätige und dann sich das Word öffnet.
D.h. ich bin im Prinzip im gespeicherten Dokument drin und dieses Dokument möchte ich exportieren. Ich hoffe die Angabe reicht...
Don Pasquale:
Hi,
ich finde die übergabe nach word mittels nummerierter felder nicht gelungen, ich hattte das mal so gelöst.
sf_ ... sind die Namen der Felder in meiner Maske.
(Ist aber eine alte version, nicht getestet)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim Reaktionsbriefpfad As String
Reaktionsbriefpfad = "c:\test\wordvolagen\testdoc.dot"
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Dim object As NotesEmbeddedObject
Dim s As New notessession
Dim heute As New notesdatetime("heute")
Dim word As Variant
Dim worddoc As Variant ' jetzt sehe ich es auch
Dim Worddokumentname As String
Dim Identnummer As String
Worddokumentname = "Reaktion"
'
'Create the Word object:
Set word = CreateObject("Word.Application") 'Create Word object
Call word.documents.add(Reaktionsbriefpfad)
Set worddoc = word.activedocument 'Get a handle for the active document
'Assign the field values:
worddoc.FormFields("NAME1").result = uidoc.FieldGetText("sf_name1")
worddoc.FormFields("HAUSNUMMER").result = uidoc.FieldGetText("sf_hausnummer")
worddoc.FormFields("POSTFACH").result = uidoc.FieldGetText("sf_postfach")
worddoc.FormFields("POSTLEITZAHL").result = uidoc.FieldGetText("sf_Postleitzahl")
worddoc.FormFields("ORT").result = uidoc.FieldGetText("sf_Ort")
worddoc.saveas(Worddokumentname) 'save the document with the filename of "user"
word.visible = True 'Comment this line if you don't want to show Word.
word.quit 'remove comment if you want to close rather than show Word.
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln