jeck09nt > 16-12-15, 05:50 PM
jeck09nt > 24-09-17, 02:42 PM
Function InsertText(docfile As Object, varText As Variant)
On Error GoTo ErrorHandler
Dim strDate As String
Dim strCurUser As String
Dim blnChensotrang As Boolean
Dim strPathpict As String
Dim strPathpict2 As String
strDate = varText(0)
strCurUser = varText(1)
blnChensotrang = varText(2)
strPathpict = varText(3)
strPathpict2 = varText(4)
With docfile
.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = ""
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = ""
With .Sections(1).Headers(wdHeaderFooterPrimary).Range
If strDate & strCurUser <> "" Then
.Text = strDate & " - " & strCurUser
'.Font.Name = "Times New Roman"
.Font.Name = "Times New Roman"
.Font.Size = "9"
.Font.Color = wdColorRed
.Paragraphs(1).Alignment = wdAlignParagraphRight
End If
End With
If strPathpict <> "" Then
.Sections.Item(1).Footers(wdHeaderFooterPrimary).Range.InlineShapes.AddPicture (strPathpict2)
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Paragraphs(1).Alignment = wdAlignParagraphLeft
.Sections.Item(1).Footers(wdHeaderFooterPrimary).Range.InlineShapes.AddPicture (strPathpict)
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Paragraphs(1).Alignment = wdAlignParagraphRight
End If
If blnChensotrang = True Then
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Font.Bold = True
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Font.Size = "9"
.Sections(1).Footers(1).PageNumbers.add (wdAlignPageNumberCenter)
End If
End With
Exit_ErrorHandler:
Exit Function
ErrorHandler:
Select Case Err.Number
Case 5152
MsgBox "Khong tim thay file: " & vbCrLf & strPathpict, , "Error InsertText: " & Err.Number
Resume Next
Case Else
MsgBox Err.Description, vbExclamation, "Error InsertText: " & Err.Number
End Select
Resume Exit_ErrorHandler
End Function