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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
Sub Enregistrer()
Dim MonDoc1, MonDoc1b, MonDoc2, MonDoc3
Dim MonFichier As String
Dim Chemin2 As String
Dim NU As String
NU = Environ("USERNAME")
If NU = "toto" Or NU = "toto" Or NU = "Roby" Then
NU = "RB"
End If
If NU = " " Or NU = " " Then
NU = "PS"
End If
If NU = " " Or NU = " " Then
NU = "TB"
End If
If NU = " " Or NU = " " Then
NU = "ER"
End If
If NU = " " Or NU = " " Then
NU = "MR"
End If
Chemin = ActiveDocument.Path & Application.PathSeparator
Chemin2 = "D:\roby\Dossier-RB\XX - Archives PSE\4 - Dossier ( Tableau )\"
MonDoc1 = Format(Date, "yyyy") & "-" & Format(Date, "mm") & "-" & Format(Date, "dd") & " " & Format(Time, "hhmm") & " ( " & NU & " ) " & ActiveDocument.Bookmarks("PPSMJ1").Range.Text & ".docm"
If Left(ActiveDocument.Bookmarks("PPSMJ1").Range.Text, 2) = "M." Then
VPPSMJ = ActiveDocument.Bookmarks("PPSMJ1").Range.Text
VPPSMJ = Replace(VPPSMJ, "M. ", "", 1, 1, 1)
MonDoc1b = VPPSMJ & " " & Format(Date, "yyyy") & "-" & Format(Date, "mm") & "-" & Format(Date, "dd") & " " & Format(Time, "hhmm") & " ( " & NU & " ) " & ".docm"
End If
If Left(ActiveDocument.Bookmarks("PPSMJ1").Range.Text, 3) = "Mme" Then
VPPSMJ = ActiveDocument.Bookmarks("PPSMJ1").Range.Text
VPPSMJ = Replace(VPPSMJ, "Mme ", "", 1, 1, 1)
MonDoc1b = VPPSMJ & " " & Format(Date, "yyyy") & "-" & Format(Date, "mm") & "-" & Format(Date, "dd") & " " & Format(Time, "hhmm") & " ( " & NU & " ) " & ".docm"
End If
MonDoc2 = Chemin2 & MonDoc1b
MonDoc3 = Chemin & MonDoc1b
NU = Environ("USERNAME")
If NU = "" Or NU = "" Or NU = "Roby" Then
ActiveDocument.SaveAs FileName:=MonDoc2
End If
'***********************************************
Dim DocEnCours As Document, DocCible As Document
Dim RepertoireCible As String
Dim I As Integer
Set DocEnCours = ActiveDocument
With DocEnCours
' RepertoireCible = .Path & "\Dossier copies\"
RepertoireCible = .Path & "\"
.Range.Copy
End With
Set DocCible = Documents.Add
With DocCible
.Range.Paste
For I = .Paragraphs.Count To 1 Step -1
With .Paragraphs(I).Range
If .Information(wdActiveEndPageNumber) > 1 Then .Delete
End With
Next I
' .SaveAs RepertoireCible & DocEnCours.Name
.SaveAs MonDoc3
.Close
End With
Set DocCible = Nothing
Set DocEnCours = Nothing
'***********************************************
'ActiveDocument.SaveAs FileName:=MonDoc3
Application.Quit (wdDoNotSaveChanges)
End Sub |
Partager