Hallo,
wie kann ich felder (z. B name, vorname)von der Datenbank in einer word-Datei direkt laden.
Danke für jede Antwort
guidi
Hallo,
wie kann ich felder (z. B name, vorname)von der Datenbank in einer word-Datei direkt laden.
Danke für jede Antwort
guidi
z.B. mit Automation aus der DB oder bel. anderer Anwendung heraus (u.a. unter Verwendung von Textmarken, Formularfeldern oder dgl. in der *.dot). Prinzipiell auch umgekehrt, wenn klar ist, welche Datensätze zur Anwendung kommen sollen.
Simples Bsp.:
Dim oWd As Object ' Word.Application
Dim oDoc As Object ' Word.Document
Dim oRange As Object ' Word.Range
On Error Resume Next
Set oWd = GetObject(, "Word.Application")
If Err 0 Then
Set oWd = CreateObject("Word.Application")
On Error GoTo 0
End If
Set oDoc = oWd.Documents.Add("c:\Test\Test.dot")
With oDoc
If .Bookmarks.Exists("Name") Then
Set oRange = .Bookmarks("Name").Range
oRange.Text = "Meier" ' bzw. dein DB-Inhalt
.Bookmarks.Add "Name", oRange
End If
' weiteres wie Dok anzeigen nach Bedarf
If oWd.Visible = False Then oWd.Visible = True
.Activate
End With
Set oDoc = Nothing
Set oWd = Nothing