W
Wendy
Hi,
I've got this code and I'm getting the above error when I run it:
Sub splitter()
'
' Splitter Macro
'
'
Dim Letters As Integer, Counter As Integer
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Docname = Trim(Selection.Text)
ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
ActiveDocument.SaveAs FileName:="D:\" & Docname
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub
The error occurs when trying to save each individual file - if I execute the
save manually with the clipboard contents at the point of breaking, the file
saves okay. Why would it not work in this macro context? Any clues? I've got
a 200 page document that needs splitting by tomorrow.
Thanks guys
Woo
I've got this code and I'm getting the above error when I run it:
Sub splitter()
'
' Splitter Macro
'
'
Dim Letters As Integer, Counter As Integer
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Docname = Trim(Selection.Text)
ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
ActiveDocument.SaveAs FileName:="D:\" & Docname
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub
The error occurs when trying to save each individual file - if I execute the
save manually with the clipboard contents at the point of breaking, the file
saves okay. Why would it not work in this macro context? Any clues? I've got
a 200 page document that needs splitting by tomorrow.
Thanks guys
Woo