begin process at 2008 09 05 21:07:28
1 237 505 membres
445 nouveaux aujourd'hui
14 313 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

VBA WORD - DÉCOUPAGE DOCUMENT EN FICHIERS HTML


Information sur la source

Description

Cette macro permet de découper chaque page d'un document Word en fichiers HTML indépendants tout en conservant la typographie et les images, etc...

Source

  • Option Explicit
  • Sub MDMain()
  • Dim Page As Integer
  • Dim StartRange As Range
  • Dim Chemin As String
  • Chemin = ActiveDocument.Path + "\"
  • Selection.HomeKey Unit:=wdStory
  • Set StartRange = Selection.Range
  • Selection.Collapse
  • While StartRange.End <= Selection.End And ActiveDocument.Content.End > Selection.End
  • Page = Page + 1
  • Selection.HomeKey Unit:=wdStory
  • Selection.Extend
  • Application.Browser.Next
  • On Error GoTo SelectionFin
  • Selection.Cut
  • GoTo Suivant
  • SelectionFin:
  • Selection.EndKey Unit:=wdStory
  • Selection.Cut
  • Suivant:
  • On Error GoTo 0
  • Documents.Add Template:="", NewTemplate:=False, DocumentType:=1
  • Selection.Paste
  • ActiveDocument.SaveAs FileName:=Chemin + "Page" + CStr(Page) + ".html", fileformat:=wdFormatHTML
  • ActiveDocument.Close savechanges:=False
  • Wend
  • End Sub
Option Explicit

Sub MDMain()
    Dim Page As Integer
    Dim StartRange As Range
    Dim Chemin As String

    Chemin = ActiveDocument.Path + "\"
    Selection.HomeKey Unit:=wdStory
    Set StartRange = Selection.Range
    Selection.Collapse
    While StartRange.End <= Selection.End And ActiveDocument.Content.End > Selection.End
        Page = Page + 1
        Selection.HomeKey Unit:=wdStory
        Selection.Extend
        Application.Browser.Next
        On Error GoTo SelectionFin
        Selection.Cut
        GoTo Suivant
SelectionFin:
        Selection.EndKey Unit:=wdStory
        Selection.Cut
Suivant:
        On Error GoTo 0
        Documents.Add Template:="", NewTemplate:=False, DocumentType:=1
        Selection.Paste
        ActiveDocument.SaveAs FileName:=Chemin + "Page" + CStr(Page) + ".html", fileformat:=wdFormatHTML
        ActiveDocument.Close savechanges:=False
    Wend
End Sub

Conclusion

En espérant que celà puisse vous être utile.
  • signaler à un administrateur
    Commentaire de glad le 15/11/2007 09:52:32

    Pour de gros documents, il faut rajouter un DoEvents avant le wend afin d'éviter que Word 2000 ne plante.

Ajouter un commentaire

Pub



Appels d'offres

CalendriCode

Septembre 2008
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
2930     

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS