jo ich habs jetzt...
es gibt nur ein problem: word wird entweder nicht korrekt geöffnet oder geschlossen...
ich muss jedes weitere mal also mit schreibgeschützt usw aufmachen...
Dim oWord As New Word.Application
Dim oDoc As New Word.Document
Dim oTable As Word.Table
Dim oPara1 As Word.Paragraph
Dim sFileName As String
Dim sSql As String
Dim oRs As New ADODB.Recordset
Dim i As Long
Dim sVersion As String
sFileName = oStdFct.vOpenDialog(OpenFileDialog1)
oDoc = oWord.Documents.Open(FileName:=sFileName)
oDoc.Tables.Item(1).Rows.Add(oDoc.Tables.Item(1).Rows.Item(2))
sSql = " select * from vgetwnew " & _
" where projekt = '" & oStdFct.vReplaceString(cmbProjekt.Text) & "'"
i = 2
oRs.Open(sSql, oConn)
sVersion = oRs(1).Value
While Not oRs.EOF
If oRs(1).Value <> sVersion Then
oDoc.Tables.Item(1).Cell(i, 1).Range.Text = oRs(1).Value & vbNewLine & Format(Date.Now, "dd.MM.yyyy")
sVersion = oRs(1).Value
Else
If i = 2 Then
oDoc.Tables.Item(1).Cell(i, 1).Range.Text = oRs(1).Value & vbNewLine & Format(Date.Now, "dd.MM.yyyy")
Else
oDoc.Tables.Item(1).Cell(i, 1).Range.Text = oRs(1).Value
End If
End If
oDoc.Tables.Item(1).Cell(i, 2).Range.Text = oRs(0).Value
oDoc.Tables.Item(1).Cell(i, 3).Range.Text = oRs(2).Value
i = i + 1
oRs.MoveNext()
End While
oRs.Close()