4
有没有办法使用VBA将RTF文本从Access数据库中的备注字段复制到Word文档中。我目前有这段代码,但它会生成html文本(文本包含标签并未格式化)。使用VBA将Access中的RTF文本复制到Word表格
' Query the database and get the sales for the specified customer
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Sales WHERE Sales.[ID] ='" & Forms![customers]![id] & "'")
'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
' Create file and add rtf text
Set ts = fso.CreateTextFile("c:\temp\temp.rtf", True)
ts.Write rs(3)
ts.Close
' Add a row
doc.Tables(1).Rows.Add
' Get the number of the added row to add data
i = doc.Tables(1).Rows.Last.Index
' Add sale to word table
doc.Tables(1).Cell(i, 2).Range.InsertFile "C:\temp\temp.rtf", , False
'Move to the next record. Don't ever forget to do this.
rs.MoveNext
Loop
Else
MsgBox "There are not records in the recordset."
End If
MsgBox "Finished." & i
rs.Close
Set rs = Nothing
有没有其他方法可以做到这一点?
请输入您当前输出的示例。 – JohnFx 2013-05-03 05:13:51