一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

VB 把數(shù)據(jù)庫(kù)導(dǎo)出給word

 jztgwq 2012-12-31
 

Dim ws As Workspace, db As Database, tb As TableDef, rs As Recordset
Dim nn As Long, errS As String
Dim Errstring As String
Private Sub Form_Load()
  Data1.DatabaseName = App.Path & "\db.mdb"
  Text1.Text = Data1.DatabaseName
End Sub
Private Sub Command3_Click()
  Dim filen As String, dirf As String, mm As String
  mm = ""
  Errstring = "這個(gè)數(shù)據(jù)庫(kù)已加密,請(qǐng)輸入密碼:"
  Comm1.FileName = "*.mdb;*.dbf"
  Comm1.Filter = "*.mdb"
  Comm1.DialogTitle = "打開(kāi)數(shù)據(jù)庫(kù)文件"
  Comm1.ShowOpen
  filen = LCase(Comm1.FileName)
  For i = Len(filen) To 1 Step -1
      dirf = Mid(filen, i, 1)
      If dirf = "\" Then
         dirf = Left(filen, i)
         Exit For
      End If
  Next
  If filen <> "*.mdb;*.dbf" Then
     List1.Clear
     Set ws = DBEngine.Workspaces(0)
     If Right(filen, 3) = "mdb" Then
        Set db = ws.OpenDatabase(filen, False, False, ";pwd=" & mm)
      Else
        Set db = ws.OpenDatabase(dirf, False, False, "FoxPro 2.6")
     End If
  End If
  For Each tb In db.TableDefs
     If Left(tb.Name, 4) <> "MSys" Then List1.AddItem (tb.Name)
  Next
  List1.Refresh
  Text1.Text = Comm1.FileName
End Sub
Private Sub Command1_Click()
  Dim i As Integer, j As Integer
  Dim ifieldcount As Integer, irecordcount As Integer
  Dim wdapp As Word.Application
  Dim wddoc As Word.Document
  Dim atable As Word.Table
  With Data1.Recordset
       Data1.Recordset.MoveLast
       Data1.Recordset.MoveFirst
       ifieldcount = .Fields.Count
       irecordcount = .RecordCount
  End With
  On Error Resume Next
  '創(chuàng)建word應(yīng)用程序,這一句話打開(kāi)word2000
  Set wdapp = CreateObject("Word.Application")
  '在word中添加一個(gè)新文檔
  Set wddoc = wdapp.Documents.Add
  With wdapp
  .Visible = True
  .Activate
  '在word中增加一個(gè)表格
  Set atable = .ActiveDocument.Tables.Add(.Selection.Range, irecordcount + 1, ifieldcount)
  For i = 0 To ifieldcount - 1
      atable.Cell(1, i + 1).Range.InsertAfter DBGrid1.Columns(i)
  Next i
  '指定表格內(nèi)容
  For i = 0 To irecordcount - 1
  For j = 0 To ifieldcount - 1
      DBGrid1.Row = i
      DBGrid1.Col = j
      atable.Cell(i + 2, j + 1).Range.InsertAfter DBGrid1.Text
  Next j
  Next i
  End With
  '清除word對(duì)象
  Set wdapp = Nothing
  Set wddoc = Nothing
End Sub

Private Sub List1_Click()
  Data1.DatabaseName = Text1.Text
  Data1.RecordSource = List1.Text
  Data1.Refresh
  DBGrid1.Refresh
End Sub
Private Sub Command2_Click()
  End
End Sub

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多

    国产不卡免费高清视频| 在线观看免费视频你懂的| 国产精品一级香蕉一区| 国产成人精品午夜福利| 深夜福利亚洲高清性感| 亚洲乱码av中文一区二区三区| 午夜资源在线观看免费高清| 色小姐干香蕉在线综合网| 91一区国产中文字幕| 一区二区三区亚洲天堂| 中文字幕不卡欧美在线| 国产一区二区精品高清免费| 午夜福利视频日本一区| 午夜福利直播在线视频| 日本在线视频播放91| 午夜福利国产精品不卡| 毛片在线观看免费日韩| 亚洲欧美日本国产不卡| 久久精品亚洲情色欧美| 亚洲一区二区三区一区| 国产又粗又猛又长又黄视频| 精品人妻少妇二区三区| 少妇特黄av一区二区三区| 亚洲国产性感美女视频| 激情综合网俺也狠狠地| 99久久人妻中文字幕| 嫩草国产福利视频一区二区| 日本人妻精品有码字幕| 福利在线午夜绝顶三级| 粉嫩国产美女国产av| 最好看的人妻中文字幕| 丝袜av一区二区三区四区五区| 国产丝袜美女诱惑一区二区| 亚洲欧美日韩网友自拍| 国产亚洲视频香蕉一区| 国产永久免费高清在线精品| 精品一区二区三区中文字幕| 国产精品蜜桃久久一区二区| 精品al亚洲麻豆一区| 91在线播放在线播放观看| 欧美黄色成人真人视频|