1.在word里用程序如何插入一个选种和未选种的checkbox,而且这个checkbox边框可以大一些。
2.我插入表格数据用 WordTab.Cell(1, 2).Range.InsertAfter "100"
但是我想在比如一个格中"第    号定单, 总计   元"插入怎么做,变成"第 100 号定单, 总计 500元"

解决方案 »

  1.   


    Sub Macro1()
        Selection.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
        Selection.MoveDown Unit:=wdLine, Count:=1
        Selection.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
        Selection.MoveDown Unit:=wdLine, Count:=1
        ActiveDocument.InlineShapes(2).OLEFormat.Object.Value = True
        ActiveDocument.InlineShapes(2).OLEFormat.Object.FontSize = 18
    End Sub
      

  2.   

    Sub Macro1()  ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=5, NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
       ActiveDocument.Tables(1).Cell(1, 1).Range.InsertAfter "第    号定单, 总计   元"End SubSub macro2()
       ActiveDocument.Tables(1).Cell(1, 1).Range.Characters(2).InsertAfter 100
       ActiveDocument.Tables(1).Cell(1, 1).Range.Characters(16).InsertAfter 500
    End Sub
      

  3.   

    第2种情况应该用自定义的域代替按下ctrl+F9插入一个域在那里。
    然后在代码里,往那个域写内容,然后更新域。否则你用别的方法,如果内容的位置变了,你不是要改代码????
      

  4.   

    狼行天下:
    再帮下忙,就是这个checkbox我说的是边框变大,不是文字变大,
      

  5.   

    请问宏如何用在vb的程序中
    ----------------------'引用Microsoft word X.0 Object Library
    ' Add a commandbutton and copy the following codes to form1Dim wordapp As New Word.Application
    Dim mydoc As New Word.Document
      
    Private Sub Command1_Click()
    wordapp.Visible = True
    Set mydoc = wordapp.Documents.Add(DocumentType:=wdNewBlankDocument)
    mydoc.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
    mydoc.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
    mydoc.InlineShapes(2).OLEFormat.Object.Value = True
    End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set mydoc = Nothing
    wordapp.Quit
    Set wordapp = Nothing
    End Sub
      

  6.   

    狼行天下:
    再帮下忙,就是这个checkbox我说的是边框变大,不是文字变大
    ----------------------------------
    明白你意思了,很麻烦.
    建议用两个LABEL来模拟
      

  7.   

    '引用Microsoft word X.0 Object Library
    ' Add a commandbutton and copy the following codes to form1Dim wordapp As New Word.Application
    Dim mydoc As New Word.DocumentPrivate Sub Command1_Click()
    wordapp.Visible = True
    Set mydoc = wordapp.Documents.Add(DocumentType:=wdNewBlankDocument)
      ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=5, NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
       ActiveDocument.Tables(1).Cell(1, 1).Range.InsertAfter "第    号定单, 总计   元"
       ActiveDocument.Tables(1).Cell(1, 1).Range.Characters(2).InsertAfter 100
       ActiveDocument.Tables(1).Cell(1, 1).Range.Characters(16).InsertAfter 500
    End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set mydoc = Nothing
    wordapp.Quit
    Set wordapp = Nothing
    End Sub
      

  8.   

    感谢:狼行天下
    顺便问最后一个问题:
    1.就是cell(1,1)由于word版本问题不确定,
    |————————————————
    |         |     标题 1|  标题2   | 
    |         |---------------------- 
    |         |   所在区1 | 所在区11 |           
    |         |————————————
    |         |   所在区2 | 所在区22 |
    |———— |———————————— 
    如上面 “所在区”,我家中机器编码时(office2000),所在区1为 .cell(2,1)
                      所在区11为 .cell(2,2)  所在区2为.cell(3,1)
    我在单位是office xp ,所在区1为 .cell(2,2)  所在区11为.cell(2,3),
                         所在区2为.cell(3,2)    所在区2为.cell(3,3)
    我总结下,就是word2000,从第二行开始不算竖的那行开始算起,而xp则每行都从竖算起,
    这样我的程序就每次都改来改去,将来怎么到客户那里用啊,你们怎么解决的?2."第    号定单, 总计   元"就是插入后能不能不让他们后退啊,象第 100 号定单, 总计   元,而有时  第 100      号定单, 总计   元,象后退了几位字符,改变了原来的位置。
      

  9.   

    '引用Microsoft word X.0 Object Library
    ' Add a commandbutton and copy the following codes to form1Dim wordapp As New Word.Application
    Dim mydoc As New Word.DocumentPrivate Sub Command1_Click()
    wordapp.Visible = True
    Set mydoc = wordapp.Documents.Add(DocumentType:=wdNewBlankDocument)
      ActiveDocument.Tables.Add Range:=selection.Range, NumRows:=5, NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
       ActiveDocument.Tables(1).Cell(1, 1).Range.InsertAfter "第    号定单, 总计   元"
    ActiveDocument.Tables(1).Cell(1, 1).Range.Characters(1).Select
    With selection
        .MoveRight Unit:=wdCharacter, Count:=1
        .MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
        .TypeText Text:="100"
        .MoveRight Unit:=wdCharacter, Count:=7
        .MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
        .TypeText Text:="500"
        End With
    End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set mydoc = Nothing
    wordapp.Quit
    Set wordapp = Nothing
    End Sub