anryo
01-07-2008, 06:52 AM
Hello,
I have found perfect macro for it, but only problem is, as it creates new document for each section - it looses all formatting information (fonts, font sizes, margins etc.).
What needs to be changed in following macro, so it uses formatting from original document?
Macro:
-----------------
Sub Split()
'
' Split Macro
' Macro created 7.01.2008 by user
'
Letters = ActiveDocument.Sections.Count
For Counter = 1 To Letters
Dim myRange As Word.Range
Set myRange = ActiveDocument.Paragraphs(1).Range
myRange.MoveEnd wdCharacter, -1
sName = myRange.Text
myRange.Paragraphs(1).Range.Delete
Docname = "C:\Merge\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
With Documents.Add
.Range.Paste
.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument
.Close
End With
Next
End Sub
I have found perfect macro for it, but only problem is, as it creates new document for each section - it looses all formatting information (fonts, font sizes, margins etc.).
What needs to be changed in following macro, so it uses formatting from original document?
Macro:
-----------------
Sub Split()
'
' Split Macro
' Macro created 7.01.2008 by user
'
Letters = ActiveDocument.Sections.Count
For Counter = 1 To Letters
Dim myRange As Word.Range
Set myRange = ActiveDocument.Paragraphs(1).Range
myRange.MoveEnd wdCharacter, -1
sName = myRange.Text
myRange.Paragraphs(1).Range.Delete
Docname = "C:\Merge\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
With Documents.Add
.Range.Paste
.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument
.Close
End With
Next
End Sub