Domino 9 und frühere Versionen > ND7: Entwicklung

Rich Text Feld als Word Object Quelldokument

<< < (2/4) > >>

ascabg:
Die Verzeichnisse der Vorlagen, die in den Optionen hinterlegt sind, solltest Du eigentlich ueber das Application-Object herausbekommen.


--- Code: ---strUserVorlagen = Application.Options.DefaultFilePath(wdUserTemplatesPath)

--- Ende Code ---
Somit bekommt man das Verzeichnis, welches als Verzeichnis fuer dei Benutzervorlagen definiert ist.


Andreas

Davidxx:
Ah super Tipp, danke.

Allerdings gibt er mir jetzt "D:Daten/Eigene Dateien" wieder, was ja nicht stimmt.
Das ist der korrekte Pfad wenn es um normale Dokumente geht, aber nicht für Vorlagen.

ascabg:
Kannst Du mal den betreffenden Code (anonymisiert natuerlich) hier posten?


Andreas

Davidxx:
klar:

'15.01.2010 DvR
Sub Click(Source As Button)
   
   On Error Goto err_handler
   
   Dim oSession As New NotesSession
   Dim ouiwks As New NotesUIWorkspace
   Dim oUIDoc As NotesUIDocument
   Dim dc As NotesDocumentCollection
   Dim oDb As NotesDatabase
   Dim oView As NotesView
   Dim strSuchbegriff As String
   Dim oDoc As NotesDocument
   Dim ocolSearch As notesdocumentcollection
   Dim vReturn As Variant
   Dim sReturn As String
   Dim vResult As Variant
   Dim vSchlagwortliste As Variant
   Dim vListe As Variant
   Dim sjoin As String
   Dim listOfViewNames As String
   Dim selected_viewname As String
   Dim oRTItemBody As NotesRichTextItem
   
   Set oDb = oSession.CurrentDatabase
   Set dc = oDb.AllDocuments
   Set oDoc = dc.GetFirstDocument
   
   'Dim wsh As Variant
   'Set wsh = CreateObject("WScript.Shell")
   
   Dim strUserVorlagen As String
   Set Application = CreateObject("Word.Application")   
   
   strUserVorlagen = Application.Options.DefaultFilePath(wdUserTemplatesPath)
   
   'Dim WshShell As Variant
   'Dim oShellLink As Variant
   'Set WshShell = CreateObject("Wscript.Shell")
   'Set oShellLink = WshShell.CreateShortcut("D:\Daten\Eigene Dateien\Eigene Bilder\Actionleiste BDB.JPG.lnk")
   'oShellLink.TargetPath = "D:\Actionleiste BDB.JPG" 
   'oShellLink.Save
   
   'Call WshShell.RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Recent Templates" )
   
   'Erfassen der Suchworte
   Dim squery  As String
   squery = |@Sort(@Unique(@DbColumn("";"";"Lösungskatalog";1)))|
   vSchlagwortliste = Evaluate(squery)
   
   Dim vUserChosenSearchKeys As Variant
   vUserChosenSearchKeys = ouiwks.Prompt(7, "Auswahl","Bitte Schlagworte auswählen", vSchlagwortliste(0),vSchlagwortliste)
   
   Dim ocolAllResults As notesdocumentcollection
   Dim ovwToSearchIn As notesview
   Dim ocoltmp As notesdocumentcollection
   Dim odoctmp As notesdocument
   
   Set ovwToSearchIn = odb.getview("Lösungskatalog")
   Set ocolAllResults = ovwToSearchIn.getalldocumentsbykey ("~~~~~~~~~~",True)
   
   'Maske Lösungskatalog erstellen
   Set oDocLoesung = New NotesDocument(oSession.CurrentDatabase)
   
   oDocLoesung.Form="Lösungskatalog"
   
   If oDocLoesung.HasItem("Body") Then Call oDocLoesung.RemoveItem("Body")
   Set oRTItemBody = New NotesRichTextItem( oDocLoesung, "Body" )
   
   Forall search_key In vUserChosenSearchKeys
      Set ocoltmp = ovwToSearchIn.getalldocumentsbykey(search_key)
      If ocoltmp.count > 0 Then
         Set odoctmp = ocoltmp.getfirstdocument
         While Not odoctmp Is Nothing
            Call ocolAllResults.addDocument(odoctmp)
            Set odoctmp = ocoltmp.getnextdocument(odoctmp)
         Wend
      End If
      Set ocoltmp = Nothing
   End Forall
   
'   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'ocolAllResults schleife (1 bis n) - aus Dokument  die Feldwerte ziehen, Feld fldInhalt +  Feldwerte aus maske "Lösungskatalog"
   Dim varSchlagworte As Variant
   Dim varKurzbez As Variant
   Dim varKunde As Variant
   Dim varProjekttitel As Variant
   Dim varKurzbeschreibung As Variant
   Dim oDocResult As NotesDocument
   Dim richStyle As NotesRichTextStyle
   Set richStyle = oSession.CreateRichTextStyle
   Set oDocResult = ocolAllResults.GetFirstDocument
   
   'Word Dokument wird erstellt
   Dim wordObj As Variant
   Dim rtItem As NotesRichTextItem
   Dim gesamtText As Variant
   
   gesamtText = oRTItemBody.GetUnformattedText
'   gesamtText = oRTItemBody.GetFormattedText(False,80)
   Set wordObj = CreateObject("Word.Application")
   wordObj.visible = True
   Call wordObj.Documents.Add("VorlageLösungskatalog.dot")
   Set wordDoc = wordObj.ActiveDocument
   
   While Not oDocResult Is Nothing
      varKurzbez = oDocResult.GetItemValue("Kurzbez")
      varKunde = oDocResult.GetItemValue("Kunde")
      varProjekttitel = oDocResult.GetItemValue("Projekttitel")
      varKurzbeschreibung = oDocResult.GetItemValue("fldKurzbeschreibung")
      
      richStyle.Bold = True
      'Zur Erkennung das es sich um eine Überschrift handelt
      
      wordObj.Selection.Font.Bold = True   'Fett einschalten
      wordObj.Selection.TypeText varProjekttitel(0)+Chr$(11)
      wordObj.Selection.Font.Bold = False  'Fett ausschalten
      
      wordObj.Selection.TypeText varKurzbez(0)+Chr$(11)
      
      wordObj.Selection.TypeText "Kunde: "
      wordObj.Selection.TypeText varKunde(0)+Chr$(11)
      
      wordObj.Selection.TypeText varKurzbeschreibung(0)+Chr(10)
      
      'nächstes Dokument
      Set oDocResult = ocolAllResults.GetNextDocument(oDocResult)
      wordObj.Selection.TypeText "___________________________________________________________________ "+Chr(10)+Chr(10)
   Wend
   
   
   'Text in das Word Dokument schreiben
   With wordObj.Selection
      .TypeText(gesamtText)
   End With 
   
   Exit Sub
   
err_handler:
   'catch the "document is already in collection error and resume next
   Msgbox Error$ & " (" & Err & ")"   & " in Zeile " & Str(Erl)    
   If Err=4469 Then Resume Next
   Exit Sub
End Sub

ascabg:
Frage.

Die von der Funktion benoetigte Konstante wdUserTemplatesPath ist aber in Deinem Code schon definiert?
Es handelt sich hierbei um eine VBA-Konstante, die es in der Form nicht in LN gibt.


Andreas

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln