doc.Paragraphs.add.Range.InsertBefore("声明")doc.Paragraphs.add.Range.InsertBefore("")
<%for i=0 to ubound(fcsm)%>
doc.Paragraphs.add.Range.InsertBefore("<%=fcsm(i)%>")
<%next%>
doc.Paragraphs.add.Range.InsertBefore("")
doc.Paragraphs.add.Range.InsertBefore("假设和限制条件")
doc.Paragraphs.add.Range.InsertBefore("")
<%for i = 0 to ubound(gjtj)%>
doc.Paragraphs.add.Range.InsertBefore("<%=gjtj(i)%>")
<%next%>
doc.Paragraphs.add.Range.InsertBefore("报告")
我想知道,我怎么写才能选中"假设和限制条件"与"报告"之间的文字.然将选中的文字的段落格式设置为(LineSpacingRule) "固定值"25磅.
我在线等...还往高手指点!! 我在其中渗加了asp语言

解决方案 »

  1.   

    好久以前用的VBA了,忘得差不多了。
    你可以用录制宏来看它生成的代码。
    应该有所启发。
      

  2.   

    好了,
    我帮你搞定了代码如下:Dim startflag As Long
    Dim endflag As Longapp.Selection.Find.ClearFormatting
    With app.Selection.Find
            .Text = "假设和限制条件"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
    End With
    app.Selection.Find.Execute
    startflag = app.Selection.Endapp.Selection.Find.ClearFormatting
    With app.Selection.Find
            .Text = "报告"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
    End With
    app.Selection.Find.Execute
    endflag = app.Selection.startapp.Selection.start = startflag
    app.Selection.End = endflag
      

  3.   

    还有设置段落格式如下:Dim para As Paragraph
    For Each para In app.Selection.Paragraphs
        para.LineSpacingRule = wdLineSpaceAtLeast
        para.LineSpacing = 25
    Next
      

  4.   

    朋友.我在我的程序里试了一下.不灵呀.
    <script language="vbscript" >
    Sub buildDoc()
    Dim startflag 
    Dim endflag 
    set objWordDoc = CreateObject("Word.Application")
    ObjWordDoc.Application.Visible=True
    readonly=false
    ObjWordDoc.Application.Documents.open("d:/test1.doc")
    set myRange =objWordDoc.Application.ActiveDocument.Range()
    set doc=objWordDoc.Application.ActiveDocument
    set doc1=objWordDoc.Application
    doc.Paragraphs.add.Range.InsertBefore("声明")doc.Paragraphs.add.Range.InsertBefore("")
    <%for i=0 to ubound(fcsm)%>
    doc.Paragraphs.add.Range.InsertBefore("<%=fcsm(i)%>")
    <%next%>
    doc.Paragraphs.add.Range.InsertBefore("")
    doc.Paragraphs.add.Range.InsertBefore("假设和限制条件")
    doc.Paragraphs.add.Range.InsertBefore("")
    <%for i = 0 to ubound(gjtj)%>
    doc.Paragraphs.add.Range.InsertBefore("<%=gjtj(i)%>")
    <%next%>
    doc.Paragraphs.add.Range.InsertBefore("报告")
    ----------------------------------------------
    doc1.Selection.Find.ClearFormatting
    With doc1.Selection.Find
            .Text = "估价的假设和限制条件"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
    End With
    doc1.Selection.Find.Execute
    startflag = doc1.Selection.Enddoc1.Selection.Find.ClearFormatting
    With doc1.Selection.Find
            .Text = "估价结果报告"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
    End With
    doc1.Selection.Find.Execute
    endflag = doc1.Selection.startdoc1.Selection.start = startflag
    doc1.Selection.End = endflagDim para 
    For Each para In doc1.Selection.Paragraphs
        para.LineSpacingRule = wdLineSpaceAtLeast
        para.LineSpacing = 25
    Next
    ----------------------------------
    End Sub
    </script>
    加在虚线上的程序好像不灵呀.. DarkChampion(暗黑骑士) 这位老师你能不能再帮我看看呀.
      

  5.   

    我试过了没有问题的。是不是因为你把
    .Text = "假设和限制条件"
    .Text = "报告"
    改为了
    .Text = "估价的假设和限制条件"
    .Text = "估价结果报告"
    而导致找不到文本。
    从而Selection对象为空。
    所以失败。