vuthaiha90 > 10-03-17, 05:29 PM
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim i As Long
Dim oApp As Object
Dim Doc As Object
Dim strDocName As String
Dim tblNoInDoc As Byte
Dim oWordTbl As Object
temp = """"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
strDocName = """" & CurrentProject.Path & "\Word\TC" & "\HDTDTC.doc" & """"
Set Doc = oApp.Documents.Add(strDocName)
Doc.FormFields("SoHDTDTC").Result = Me.SoHDTDTC
'................................................................................
If DLookup("SokytraTC", "T_infovayTC") = 1 Then
Doc.Tables(1).Select
oApp.Selection.Rows.Add
oApp.Selection.Rows.Add
oApp.Selection.Columns.Add
oApp.Selection.Columns.Add
oApp.Selection.Columns.Add
Doc.Tables(1).Cell(1, 1).Range.Text = "Ngày, Tháng, N" & ChrW(259) & "m tr" & ChrW(7843) & " n" & ChrW(7907)
Doc.Tables(1).Cell(2, 1).Range.Text = Me.NgaydenhanTC
Doc.Tables(1).Cell(1, 2).Range.Text = "S" & ChrW(7889) & " ti" & ChrW(7873) & "n tr" & ChrW(7843) & " n" & ChrW(7907)
Doc.Tables(1).Cell(2, 2).Range.Text = Format(Me.SotienvayTC, "#,##0") & ChrW$(273)
Doc.Tables(1).Cell(1, 3).Range.Text = "Ngày, Tháng, N" & ChrW(259) & "m tr" & ChrW(7843) & " n" & ChrW(7907)
Doc.Tables(1).Cell(1, 4).Range.Text = "S" & ChrW(7889) & " ti" & ChrW(7873) & "n tr" & ChrW(7843) & " n" & ChrW(7907)
Doc.Tables(1).Columns.AutoFit
With Doc.Tables(1).Rows(1).Range
.Font.Bold = True
.ParagraphFormat.Alignment = 1
.Cells.VerticalAlignment = 1
End With
Doc.Tables(1).AutoFitBehavior (wdAutoFitWindow)
' Hoặc em viết như này nó cũng không chạy căn giữa:
'With Doc.Tables(1)
'.AutoFitBehavior wdAutoFitWindow
'End With
End If
oApp.ActiveDocument.SaveAs Filename:="""" & CurrentProject.Path & "\Preview\TC" & "\" & "HDTDTC" & "_" & DLookup("Nguoidaidien", "T_KH2") & "_" & Me.DonvayTCngaychu & ".doc" & """"
Set oApp = Nothing
hieuvn > 10-03-17, 05:51 PM
Selection.Tables(1).Rows.Alignment =1
Tables(1).Range.ParagraphFormat.Alignment = 1
vuthaiha90 > 10-03-17, 05:57 PM