Tout d'abord merci d'avoir pris le temps de jeter un coup d'oeil,
je te fais part du code de ma macro sous word.
Je met tout le code, on ne sait jamais.
"
Attribute VB_Name = "Export_Certif"
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As
String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Sub Export_Certif()
'
' test Macro
Dim retourINI
Dim apporteur
Dim test As Boolean
Dim document1, f
Dim directory
Dim rep, fichier
Dim savefile
Dim fs, fs1, prnt
'on recherche sur quel apporteur on travaille
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Votre conseiller ADEP:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
apporteur = Selection
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
If (LireINI("blocage", "bloc")) <> 1 Then
retourINI = EcrireINI("blocage", "bloc", "1")
ChangeFileOpenDirectory ("R:\SANTE\")
directory = "R:\SANTE\"
fichier = apporteur + "_" + Right(Date, 4) + Mid(Date, 4, 2) +
Left(Date, 2) + ".doc"
savefile = directory + fichier
' ActiveDocument.ExportAsFixedFormat OutputFileName:= _
savefile, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint,
Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent,