Domino 9 und frühere Versionen > Entwicklung

Dokumentenverknüpfung Word-Vorlage

<< < (2/3) > >>

volti0815:
Hallo Leute,

leider bin ich jetzt erst dazu gekommen, mich mit dem Problem nochmals zu beschäftigen. Ich habe mittels eurer Tipps folgendes Script geschrieben:

Sub Click(Source As Button)
   Dim session As New NotesSession   
   Dim workspace As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Set uidoc = workspace.CurrentDocument   
   
   Dim word As Variant
   Dim wordoc As Variant
   
   Dim user As String
   
'Predefined values: (replace with field values from uidoc)
   user = uidoc.FieldGetText("From")
   
'Create the Word object:
   Set word = CreateObject("Word.Application") 'Create Word object
   Call word.documents.add("c:\temp\test.dot") 'Create a new document based on the template "test.dot"
   Set worddoc = word.activedocument 'Get a handle for the active document
   
'Assign the field values:
   worddoc.FormFields("User").result = user
   
End Sub

Leider tut sich gar nichts, wenn ich auf den Button klicke. Ich erhalte noch nicht mal ne Fehlermeldung. Was mache ich falsch? Ich muss dazu sagen, dass ich von Lotus Script so gut wie keine Ahnung habe.

Gruß

Martin

ata:
... gibt es in deiner Word-Vorlage denn das Feld "User" ?

ata

volti0815:
Ich habe das Script mal an einem anderen PC ausprobiert. Jetzt kommt die Fehlermeldung: "
Microsoft Word: Dieser Befehl ist nicht verfügbar, weil kein Dokument geöffnet ist. "
Eine Textmarke "User" ist im Word-Dokument vorhanden. Aber auch wenn ich das Feld aus dem Script entferne, und nur versuche das Dokument in Word zu öffnen, kommt die gleiche Fehlermeldung.

Gruß

Martin

ata:
... Textmarke ist nicht gleich Formularfeld - und das sprichst du mit deinem Script an - wenn du etwas Zeit hast, dann geh ich mal in meiner KnowledgeBase auf die Suche, ansonsten probier es doch mal im LDD - Suche nach "Word" - du wirst hunderte verschiedener Scripte finden, die funktionieren - ansonsten in einer halben Stunde hier (Essen fassen geht vor...)

ata

ata:
... hier auf die schnelle ein Code-Schnipsel für Textmarken (Bookmarks) und anschließendem ausdrucken...


--- Code: ---In a customer/sales tracking database we needed functionality to print out
letters using predefined word templates.

Include the code in a button and try it.

Code

'Defining variables
Dim myApp As Variant
Dim tmp as string

'Starting ms word as a ole object
Set myApp = CreateObject("Word.Application")

'Hiding word from the user
myApp.Visible = False

'Opening the template as a new doc, change tmp$ to the needed template path
myApp.Documents.Add (tmp$)

'Selecting what bookmark to write to
myApp.ActiveDocument.Bookmarks("WhoTo").Select

'Define what you need to write in tmp$
'Then write it to the bookmark
myApp.Selection.TypeText(tmp$)

'Setting word to print in the foreground, i do this to prevent the rest of the
code to execute before word is finished
myApp.Options.PrintBackground = False

'Starting printing
myApp.ActiveDocument.PrintOut

'Closing the word document without saving changes
myApp.Documents.Close(wdDoNotSaveChanges)

'Closing word
myApp.Application.Quit

'Releasing myapp
Set myApp = Nothing


Finished. We use this together with templates that uses sub forms that need
inputs from the user before launching the document. Please feel free to contact
us for any further information on this isue.

--- Ende Code ---

... wobei bei diesem Code die Konstante "wdDoNotSaveChanges" noch deklariert werden muß...

... der Fehler bei dir könnte sein, daß die .dot-Datei eventuell nicht vorliegt...

ata

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln