Outcome Base Education OBE |CLO |PLO

Описание к видео Outcome Base Education OBE |CLO |PLO

In this video, i have developed an Excel Program developed in VBA " that how to make a combine warning letters (PDF file) of different students failing their CLO, PLO (OBE System)
Where u find bug insert angled bracket.

Following is the VBA Code.

Sub Warningletters()

Dim WApp As New Word.Application
Dim WDoc As Word.Document
'
WApp.Visible = True
lastrow1 = Sheet1.Range("L" & Rows.Count).End(xlUp).Row
For CLintNO = 1 To lastrow1
Sheet1.Range("i2") = Sheet1.Range("L" & CLintNO).Value
Set WDoc = WApp.Documents.Open(ThisWorkbook.Path & "\Letter Sample.docx", False)

With WDoc.Content.Find
.Text = "#Student Name#"
.Replacement.Text = Sheet1.Range("i2")
.Execute Replace:=wdReplaceAll

End With
lastrow = Sheet1.Range("H" & Rows.Count).End(xlUp).Row

Dim Tbl As Word.Table
Dim cell As Word.cell

Set Tbl = WDoc.Tables(1)
For datarow = 4 To lastrow
If datarow lastrow Then Tbl.Rows.Add
For datacol = 1 To 4 'filter data column from H to K

Set cell = Tbl.cell(datarow - 2, datacol)
cell.Range.Text = Sheet1.Cells(datarow, datacol + 7)

Next datacol
Next datarow
'WDoc.ExportAsFixedFormat ThisWorkbook.Path & "\" & Sheet1.Range("i2") & ".pdf", wdExportFormatPDF
WDoc.SaveAs2 (ThisWorkbook.Path & "\WordFiles\" & Sheet1.Range("i2") & ".docx")
WDoc.Close
Next CLintNO
WApp.Quit
Set WDoc = Nothing
Set WApp = Nothing
Dim WordApp As Word.Application
Dim Doc As Word.Document
Dim Warningletters As Word.Document
Dim filename As String
Dim a As Integer
Set WordApp = New Word.Application
WordApp.Visible = True
filename = Dir(ThisWorkbook.Path & "\WordFiles\*.docx")
Set Doc = WordApp.Documents.Add
Doc.SaveAs2 ThisWorkbook.Path & "\All Warning Letters.docx"
a = 0
Do While filename ""
Set Warningletters = WordApp.Documents.Open(ThisWorkbook.Path & "\WordFiles\" & filename)

Warningletters.Range.Copy
Doc.Activate
If (a 0) Then
WordApp.Selection.InsertBreak wdPageBreak

End If
WordApp.Selection.Paste
Warningletters.Close savechanges:=False
a = a + 1
filename = Dir()
Loop
Doc.Save
Doc.ExportAsFixedFormat ThisWorkbook.Path & "\All Warning Letters.pdf", wdExportFormatPDF
Doc.Close
WordApp.Quit
Kill ("D:\Letters\All Warning Letters.docx")
End Sub

Комментарии

Информация по комментариям в разработке