我使用如下代码启动了word,建立了一个docunment,
set wordapp1=createobject("word.application")
set worddocument1=wordapp1.documents.add
set sorddocument1=wordapp1.activedocument
现在要向里面写入字符(是数据库里面的数据),该怎么写 。
谢谢!!

解决方案 »

  1.   

    wordapp1.ActiveDocument.Content.Text = "Hi"
    把上邊的字符換成數据庫里面的就行
      

  2.   

    '当前文档添加一段
    ActiveDocument.Paragraphs.Add
    '设置当前文档的第一段的内容为“内容”二字。
    ActiveDocument.Paragraphs(1).Range.Text = "内容"http://b4018.xici.net(欢迎前往提问。)
    提供:VB、VBA、Office二次开发免费技术支持;
    承接:各类项目开发,如MIS系统,WEB网站,中小型应用软件等等;CO.:Vansoft Workroom
    MSN:[email protected]
    Email:[email protected]
           [email protected]
    TEL:025-86685867(范,24H)
      

  3.   

    '引用Microsoft Word 9.0 Object Library
    Private Sub Command1_Click()
    Set wrdApp = New Word.Application           '写word文档
    With wrdApp
    'Show Word
    .Visible = True
    'Create New Document
    .Documents.Add
    'Add text to the document
    .ActiveDocument.Content.Text = "Hello"
    .ActiveDocument.Content.Text = "This is a test example"
    End With
    End SubPrivate Sub Command2_Click()
     Dim sFileName, sContent, sPartContent As String   '打开word文档
        Dim wrdApp As Object
        Dim k As String
        CommonDialog1.ShowOpen
        If Err <> 0 Then Exit Sub
        sFileName = CommonDialog1.FileName
        If sFileName = "" Then Exit Sub
        Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        wrdApp.Documents.Open (sFileName)
        sContent = wrdApp.ActiveDocument.Content
    End Sub
      

  4.   

    Selection.TypeText Text:="any char"