定义一个OleDbCommand,把OleDbCommandBuilder的insertCommand给他,在语句后面加个断点就能看到
成都创新互联是一家专注于成都网站设计、网站建设与策划设计,平泉网站建设哪家好?成都创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:平泉等地区。平泉做网站价格咨询:18982081108
你可以先手动生成一个空白的doc后缀的文档,这个兼容性好。
然后在vb里面打开这个模板文件,编辑以后另存为一个你自定义的文件。
打开文件方式创建word对象:
dim wrdApp
dim wrdDoc
set wrdApp = CreateObject("word.application")
wrdApp.visible = true
set wrdDoc = wrdApp.documnets.open(yourFilepath)
'以下是我编辑word的示范代码:
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
'Selection.Font.Bold = wdToggle
Selection.Font.Size = 24
Selection.TypeText Text:=kj
Selection.Font.Size = 36
Selection.TypeText Text:=a(0) vbCrLf
Selection.Font.Size = 18
Selection.TypeText Text:="——" a(1) vbCrLf vbCrLf
'Selection.MoveLeft Unit:=wdCharacter, Count:=2
'Selection.TypeText Text:=" "
'Selection.MoveRight Unit:=wdCharacter, Count:=1
'Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
Selection.ParagraphFormat.SpaceBefore = 10 '段前
Selection.ParagraphFormat.SpaceAfter = 20 '段后
Selection.ParagraphFormat.LineSpacingRule = wdLineSpaceExactly '固定值
Selection.ParagraphFormat.LineSpacing = 36 '18磅
Selection.ParagraphFormat.FirstLineIndent = Word.MillimetersToPoints(18) '首行缩进0.75厘米
'Selection.Font.Name = "宋体"
Selection.Font.Size = 24
Dim duan, mylen
mylen = Len(Text1.Text)
duan = Int(mylen \ 3000)
For i = 0 To duan - 1
Selection.TypeText Text:=Mid(mytext, 3000 * i + 1, 3000)
Next
Selection.TypeText Text:=Mid(mytext, 3000 * duan + 1, mylen - (3000 * duan))
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Size = 24
'Selection.Font.Bold = wdToggle
Selection.TypeText Text:=hx
'以下是我销毁对象的代码
Private Sub myQuit(myobject As Object)
If TypeName(myobject) "Nothing" Then
Set myboject = Nothing
End If
End Sub
'销毁word对象
Call myQuit(wrdDoc)
在循环体内加入DoEvents语句就OK。
但你的循环体没有设定条件,也很有问题,会一直循环不能跳出。