Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: MartinG am 11.12.02 - 10:43:28
-
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.
-
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
-
... von wo aus agierst du denn, wo hast du den Code eingefügt?
ata
-
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...
-
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.
-
hi,
muss wohl heissen "dim worddoc" und nicht "wordoc"...
;D
-
hi klaussal,
äh, an welcher stelle ?
Don Pasquale
-
... Dim worddoc As Variant...
ata
-
das D wurde nachgereicht
derselbe fehler ist auch im script von martin_georg
wenn das mal kein zufall ist :-)
Ciao
Don Pasquale
-
Ich hoffe ich nerve nicht zu sehr... - aber Dein Script bringt bei mir leider eine Menge Fehlermeldungen...
Unexpected Endif....
Gibts es keine einfache Zeile die mein Script von oben verwendet und wo ich einfach irgendwie die Feldwerte übergeben kann?
-
aber klar probier mal das,
aber gib nicht wieder gleich auf nur weil
mal ein fehler kommt :-)
Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim doc As NotesDocument
Set uidoc = uiws.CurrentDocument
Set doc = uidoc.Document
Dim s As New notessession
'Dim todaydate As New notesdatetime("Today")
Dim word As Variant
Dim worddoc As Variant
Dim orderid As String
orderid = uidoc.fieldgettext("deinfeldname")
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(2).result = orderid
-
:) - Don Pasquale Du bist der beste!!!
Jetzt funktionierts absolut perfekt... - vielen Dank. Sorry wenn ich mich etwas dämlich anstelle. Habe auch bei Deinem Script sicherlich eine Stunde rumgemacht bin aber einfach nicht weitergekommen.
:) :) :) :) :)
-
@martin,
kannst auch mal hier gucken:
http://www.sns1.de/partner/flamme/wflamme.nsf/WordInterface1 (http://www.sns1.de/partner/flamme/wflamme.nsf/Shortcut/WordInterface1)
-
@wflamme
... sorry, der Link geht bei mir nicht...
ata
-
try this
http://www.sns1.de/partner/flamme/wflamme.nsf/Shortcut/WordInterface1
ciao
Don Pasquale
-
@Don Pasquale
... thanks a lot - ond scho duats... ;D ;D ;D
ata
-
@wflamme
... sorry, der Link geht bei mir nicht...
ata
Hast ja recht... peinlich. Hab's im Ursprungsposting korrigiert..