|
Option Compare Database Option Explicit Private Sub cmdAceptar_Click() '---Written by Helen Feddema 26-Oct-2006 '---Last modified 17-Feb-2007
On Error GoTo ErrorHandler
Dim appWord As Word.Application Dim doc As Word.Document Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim strTemplatePath As String Dim strTemplateName As String Dim strTemplateNameAndPath As String Dim strRecipientZip As String Dim strPrompt As String Dim strTitle As String Dim strSalutation As String Dim fso As New Scripting.FileSystemObject Dim fil As Scripting.File Dim prps As Object Dim MyDir As String Dim strSaveName As String Dim strDocsPath As String Dim strSaveNameAndPath As String Dim strSQL As String Dim strNombreEmpresa As String Dim strApoderado As String Dim strCalleNumero As String Dim strMunicipio As String Dim strProvincia As String Dim strCif As String Dim strNombreSocioAuditor As String Dim strCalleNumeroAuditor As String Dim strMunicipioAuditor As String Dim strProvinciaAuditor As String Dim strCifSocioAuditor As String Dim strFechaFinEjercicio As String Dim strFechaEmisionInforme As String Dim strCodigoPostal As String Dim strCodPostalAuditor As String Dim strEjercicio As String Dim SWError As Integer Screen.MousePointer = 11
'---Extrae datos de la tabla strNombreEmpresa = IsNull(DLookup("[NombreEmpresa]", "tblAuditario", "[IdAuditario] = 1")) If strNombreEmpresa = "Verdadero" Then SWError = 1 MsgBox ("Mungon emri i shoqërisë") End If strApoderado = IsNull(DLookup("[Apoderado]", "tblAuditario", "[IdAuditario] = 1")) If strApoderado = "Verdadero" Then SWError = 1 MsgBox ("Mungon emri i përfaqësuesit") End If strCalleNumero = IsNull(DLookup("[CalleNumero]", "tblAuditario", "[IdAuditario] = 1")) If strCalleNumero = "Verdadero" Then SWError = 1 MsgBox ("Mungon rruga dhe numri i shoqërisë") End If strMunicipio = IsNull(DLookup("[Municipio]", "tblAuditario", "[IdAuditario] = 1")) If strMunicipio = "Verdadero" Then SWError = 1 MsgBox ("Mungon rrethi i shoqërisë") End If strProvincia = IsNull(DLookup("[Provincia]", "tblAuditario", "[IdAuditario] = 1")) If strProvincia = "Verdadero" Then SWError = 1 MsgBox ("Mungon qyteti") End If strCif = IsNull(DLookup("[Cif]", "tblAuditario", "[IdAuditario] = 1")) If strCif = "Verdadero" Then SWError = 1 MsgBox ("Mungon NIPT") End If strCodigoPostal = IsNull(DLookup("[CodigoPostal]", "tblAuditario", "[IdAuditario] = 1")) If strCodigoPostal = "Verdadero" Then SWError = 1 MsgBox ("Mungon Kodi postar") End If strNombreSocioAuditor = IsNull(DLookup("[NombreSocioAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strNombreSocioAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon emri i auditorit") End If strCalleNumeroAuditor = IsNull(DLookup("[CalleNumeroAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strCalleNumeroAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon rruga dhe numri i auditorit") End If strMunicipioAuditor = IsNull(DLookup("[MunicipioAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strMunicipioAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon rrethi i auditorit") End If strProvinciaAuditor = IsNull(DLookup("[ProvinciaAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strProvinciaAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon qyteti i auditorit") End If strCifSocioAuditor = IsNull(DLookup("[CifSocioAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strCifSocioAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon emri i auditit") End If strCodPostalAuditor = IsNull(DLookup("[CodPostalAuditor]", "tblAuditario", "[IdAuditario] = 1")) If strCodPostalAuditor = "Verdadero" Then SWError = 1 MsgBox ("Mungon kodi postar i auditit") End If strFechaFinEjercicio = IsNull(DLookup("[FechaFinEjercicio]", "tblAuditario", "[IdAuditario] = 1")) If strFechaFinEjercicio = "Verdadero" Then SWError = 1 MsgBox ("Mungon data e mbarimit të vitit ushtrimor") End If strFechaEmisionInforme = IsNull(DLookup("[FechaEmisionInforme]", "tblAuditario", "[IdAuditario] = 1")) If strFechaEmisionInforme = "Verdadero" Then SWError = 1 MsgBox ("Mungon data e lëshimit të raportit") End If strCodigoPostal = IsNull(DLookup("[CodigoPostal]", "tblAuditario", "[IdAuditario] = 1")) If strCodigoPostal = "Verdadero" Then SWError = 1 MsgBox ("Mungon kodi postar i shoqërisë") End If If SWError = 1 Then Screen.MousePointer = 0 MsgBox "Ju nuk mund të gjeneroni letrën e manifesteve për shkak të mungesës së të dhënave. Të dhënat mund të përfshihen nga Fillimi -0: Importimi dhe përgatitja e të dhënave-", , "epAudit" Exit Sub End If strEjercicio = Year(CDate(strFechaFinEjercicio))
'---The Set wrd = GetObject("","Word.Application") is to test whether Word is already open. Set appWord = GetObject(, "Word.Application") 'Get default User Template path strTemplatePath = Application.CurrentProject.Path & "\" & "..\" & "I përhershëm\Modelet\" strTemplateName = "19 Letra e drejtimit.dotx" strTemplateNameAndPath = strTemplatePath & strTemplateName 'Get default User Doc path strDocsPath = Application.CurrentProject.Path & "\" & "I përgjithshëm\Faza2\19 Letra e drejtimit\" strSaveName = "Letra e drejtimit.docx" strSaveNameAndPath = strDocsPath & strSaveName On Error Resume Next
'---Try to locate template in default Templates folder, and put up message if it is not found Set fil = fso.GetFile(strTemplateNameAndPath) If fil Is Nothing Then strPrompt = "Nuk u gjet " & strTemplateName & " në " & strTemplatePath & "; anulohet" MsgBox strPrompt, vbCritical + vbOKOnly GoTo ErrorHandlerExit End If On Error GoTo ErrorHandler '---Opens the specified document and adds it to the Documents collection. Returns a Document object. Set doc = appWord.Documents.Add(strTemplateNameAndPath) '---Write information to Word doc properties Set prps = doc.CustomDocumentProperties prps.Item("NombreEmpresa").Value = strNombreEmpresa prps.Item("Apoderado").Value = strApoderado prps.Item("CalleNumero").Value = strCalleNumero prps.Item("Municipio").Value = strMunicipio prps.Item("Provincia").Value = strProvincia prps.Item("Cif").Value = strCif prps.Item("CodigoPostal").Value = strCodigoPostal prps.Item("NombreSocioAuditor").Value = strNombreSocioAuditor prps.Item("CalleNumeroAuditor").Value = strCalleNumeroAuditor prps.Item("MunicipioAuditor").Value = strMunicipioAuditor prps.Item("ProvinciaAuditor").Value = strProvinciaAuditor prps.Item("CodigoPostalAuditor").Value = strCodPostalAuditor prps.Item("FechaEmisionInforme").Value = Format(strFechaEmisionInforme, "d") & " de " & _ Format(strFechaEmisionInforme, "mmmm") & " de " & _ Format(strFechaEmisionInforme, "yyyy") '---Update fields With appWord .Visible = True .Selection.WholeStory .Selection.Fields.Update .ActiveDocument.SaveAs strSaveNameAndPath .Activate .Selection.HomeKey unit:=wdStory End With ErrorHandlerExit: Set appWord = Nothing Exit Sub
ErrorHandler: If Err = 429 Then '---Word is not running; open Word with CreateObject Set appWord = CreateObject("Word.Application") Resume Next Else MsgBox "Error No: " & Err.Number _ & "; Description: " & Err.Description Resume ErrorHandlerExit End If
End Sub
Private Sub cmdVerCarpetaMani_Click() Dim ProjPath ProjPath = CurrentProject.Path & "\" & "I përgjithshëm\Faza2\19 Letra e drejtimit" Shell "C:\WINDOWS\explorer.exe """ & ProjPath & "", vbNormalFocus End Sub Private Sub cmdVerCarpetaAceptación_Click() Dim ProjPath ProjPath = CurrentProject.Path & "\" & "general\1 Planificación\1 Aceptación" Shell "C:\WINDOWS\explorer.exe """ & ProjPath & "", vbNormalFocus End Sub
Private Sub MasInfo_Click() Dim ProjPath ProjPath = CurrentProject.Path & "\" & "..\" & "I përhershëm\Më shumë informacion" Shell "C:\WINDOWS\explorer.exe """ & ProjPath & "", vbNormalFocus End Sub
|