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 51
| Option Explicit
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub AutoOpen()
Dim objDoc As Document, docp As Document, Tableau() As String, i As Integer, fichier As String
Set docp = Application.ActiveDocument
Set objDoc = Application.Documents.Open("Z:\TMP\d_xxxxxx.txt")
' MsgBox objDoc.Sentences.Item(1)
Tableau = Split(objDoc.Sentences.Item(1), ";")
'boucle sur le tableau pour visualiser le résultat
' For i = 0 To UBound(Tableau)
' 'Le résultat s'affiche dans la fenêtre d'execution de l'éditeur de macros
' MsgBox Tableau(i)
' Next i
objDoc.Close
Set objDoc = Nothing
' Ouverture du .doc lié à l'ERNT, attention document non obligatoire
fichier = "J:\Locatif\BAIL\ERNT\" & Tableau(0) & ".doc"
If Dir(fichier) <> "" Then
Set objDoc = Application.Documents.Open(fichier)
Set objDoc = Nothing
End If
' Ouverture de l'ERNT, document non obligatoire
fichier = "J:\Locatif\BAIL\ERNT\" & Tableau(0) & ".PDF"
' ShellExecute 0, "open", fichier, "", "", 0
' Traitement du DPE
fichier = "J:\Locatif\BAIL\DPE\"
If Tableau(2) >= "A" Then
fichier = fichier & Tableau(1) & "-" & Tableau(2) & "-" & Tableau(3) & "-" & Tableau(4) & "-" & Tableau(5) & "D.PDF"
' MsgBox fichier
' ShellExecute 0, "open", fichier, "", "", 0
End If
docp.Activate
End Sub |
Partager