title image


Smiley Re: Datenübernahme in Word-Formular
Das geht per Automation, z.B. in Form einer Tabelle:Dim RS As Recordset, DB As Database, Where, SQL, Tmp, Fld As Field, _WordObj As Word.Application, WordTbl As Word.Table, WordDoc As Word.Document On Error Resume Next Set WordObj = GetObject(, "Word.Application ") If Err.Number 0 Then Set WordObj = CreateObject("Word.Application") On Error GoTo 0 With WordObj .Application.Visible = True Set WordDoc = .Documents.Add("I:\Samples\vorlage.dot") With .Selection .Goto What:=wdGoToBookmark, Name:="Tabelle" Set DB = CurrentDb() Where = "" If Not IsNull(Me!FilterNachname) Then Where = Where & " AND Nachname LIKE '" & Me!FilterNachname & "*'" If Not IsNull(Me!FilterOrt) Then Where = Where & " AND Ort LIKE '" & Me!FilterOrt & "*'" SQL = "SELECT Nachname, Vorname, PLZ, Ort FROM MeineTabelle " If Where "" Then SQL = SQL & "WHERE " & Mid(Where, 5) SQL = SQL & " ORDER BY Nachname, Ort" Set RS = DB.OpenRecordset(SQL, dbOpenDynaset) Set WordTbl = WordDoc.Tables.Add(Range:=WordDoc.Range, NumRows:=1, _ NumColumns:=RS.Fields.Count, DefaultTableBehavior:=wdWord9TableBehavior, _ AutoFitBehavior:=wdAutoFitFixed) Do While Not RS.EOF For Each Fld In RS.Fields .TypeText Text:=CStr(Nz(Fld.Value, "")) .MoveRight Unit:=wdCell Next Fld RS.MoveNext Loop .Rows.Delete End With .ActiveDocument.SaveAs FileName:="""" & Me!FName & """", FileFormat:=wdFormatDocument .Application.Quit End With RS.Close Set DB = Nothing Set WordTbl = Nothing Set WordDoc = Nothing Set WordObj = NothingReinhard


Gruß aus dem Norden
Reinhard


Bitte immer die Access-Version angeben!
DB-Wiki


Wie man Fragen richtig stellt

YaccessAccess-FAQUnd ansonsten: Wikipedia




geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: