vuthaiha90 > 03-07-17, 05:22 PM
Dim dbs As Database
Dim rst As Recordset
Dim i, y As Long, Tong As Long
Dim oApp As Object
Dim Doc As Object
Dim strDocName As String
temp = """"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Q_STKDH", dbOpenDynaset)
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
strDocName = """" & CurrentProject.Path & "\Word\CC" & "\Mau so 01_Phuong an su dung von.doc" & """"
Set Doc = oApp.Documents.Add(strDocName)
If rst.EOF Then
Exit Sub
Else
rst.MoveFirst
End If
y = 3
Tong = 0
Do Until rst.EOF
Doc.Tables(2).Cell(y, 1).Range.Text = rst.Fields![STT].Value
Doc.Tables(2).Cell(y, 2).Range.Text = rst.Fields![TenTS].Value
Doc.Tables(2).Cell(y, 3).Range.Text = rst.Fields![SosoTK].Value
Doc.Tables(2).Cell(y, 4).Range.Text = Format(rst.Fields![Trigiaso].Value, "##,##0") & ChrW$(273)
Doc.Tables(2).Cell(y, 5).Range.Text = IIf(rst.Fields![Kyhan].Value < 10, "0" & rst.Fields![Kyhan].Value, rst.Fields![Kyhan].Value) & " tháng"
Doc.Tables(2).Cell(y, 6).Range.Text = rst.Fields![Laisuatgui].Value & "%/n" & ChrW$(259) & "m"
Doc.Tables(2).Cell(y, 7).Range.Text = rst.Fields![Noiphathanh].Value
Doc.Tables(2).Cell(y, 8).Range.Text = rst.Fields![Ngaydenhan].Value
Tong = Tong + rst.Fields![Trigiaso].Value
rst.MoveNext
y = y + 1
Doc.Tables(2).Rows.Add
Loop
rst.Close
ongke0711 > 03-07-17, 06:36 PM
tranthanhan1962 > 03-07-17, 11:42 PM