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 70 71
|
Sub Export_word3()
Dim MonFichier As String, MonFichierHtml As String
Dim WordApp As Object, WordDoc As Object
'Dim WordApp As Word.Application, WordDoc As Word.Document
Dim I As Integer, NbTables As Integer
MonFichier = ActiveWorkbook.Path & "\" & "PROGRAMME DE TRAVAIL\PROGRAMME DE TRAVAIL.docx" ' A adapter
MonFichierHtml = ActiveWorkbook.Path & "\HTML\PROGRAMME DE TRAVAIL.htm"
On Error Resume Next
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Open(MonFichier)
NbTables = WordDoc.Tables.Count
Sheets("LISTE").Range("A1:P45").Copy
With WordApp.Selection
.EndKey unit:=6 'wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
End With
Sheets("GENERAL").Range("B1:Z160").Copy
With WordApp.Selection
.EndKey unit:=6 'wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
End With
Sheets("PREPARATION").Range("A2:M46").Copy
With WordApp.Selection
.EndKey unit:=6 'wdStory
.Paste
.TypeParagraph ' saut d'une ligne a la fin du tableau
End With
Application.CutCopyMode = False
With WordDoc
For I = NbTables + 1 To NbTables + 3
.Tables(I).PreferredWidth = 0
Next I
.Save
' .Close savechanges:=True
.SaveAs2 Filename:=MonFichierHtml, FileFormat:= _
wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=0
WordApp.ActiveWindow.View.Type = wdWebView
End With
' WordApp.Quit
MsgBox "Copie Effectuée!"
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub |
Partager