1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Private m_objWord As Word.Application
Private m_objDoc As Word.document
Public Sub CreateVisa(Student_Name As String, Agent_name As String, Agent_Adress As String, Agent_Country As String, Date_From As String, Date_To As String, Passport As String, He1 As String, His1 As String, His2 As String, FirstName As String, Birth_Date As String)
Dim recv As Recordset
Dim Reci As Recordset
Dim Dbv As Database
Dim document As String
Set m_objWord = New Word.Application
Set m_objDoc = m_objWord.Documents.Add(Trim(recv![Model_Folder]) & Trim(recv![Visa_Model_Name]), , , True)
'Save File required before closing to prevent a window at exit
document = Trim(recv![Generated_Folder]) & Student_Name & "_Visa.DOC"
'Insert Filename in header
InsertTextAtBookMark "Filename", Student_Name & "_Visa.DOC"
On Error Resume Next
Kill document
m_objDoc.SaveAs Filename:=document
'Set word in visible state
m_objWord.Visible = True
'Activate Word and printpreview the created document
m_objDoc.Activate
'Print Preview the document
m_objDoc.PrintPreview
'Wait for printpreview window closed
Do While m_objWord.PrintPreview = True
Loop
'Close all words instances
m_objDoc.ActiveWindow = False
On Error Resume Next
m_objDoc.Close
recv.Close
Reci.Close
On Error Resume Next
m_objWord.Quit
Set m_objDoc = Nothing
exit_create_visa:
End Sub |
Partager