sscottincanyon
asked on
Automatically Extract last 50 pages of mutliple documents
I feel this to be a extremely difficult problem. I have searched through Expert Exhange and numerous other website and forums. It is extremely urgent as my client needs this project completed.
I have several thousand .rtf files that I need to copy the last 50 pages of each file into another file so as to end up with several thousand files of 50 pages each, but only the last 50 pages. The files are various sizes. If I were after the first 50 pages, or if they were all identical size, this would be a no brainer. This needs to be automated to run through all several thousand files.
I have several thousand .rtf files that I need to copy the last 50 pages of each file into another file so as to end up with several thousand files of 50 pages each, but only the last 50 pages. The files are various sizes. If I were after the first 50 pages, or if they were all identical size, this would be a no brainer. This needs to be automated to run through all several thousand files.
Use i.e. MS Word to paginate whole document and cut last 50 pages to a new doc, repeat for each doc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help. The macro works great on a single document. I guess I am still not quite getting it. I have not been able to get the "for each" loop to work within the macro. I have tried starting with
strDoc = Dir(Path & "*.Doc")
Do While strDoc <> ""
and have tried various combinations to complete the loop, but it just isn't working. Any ideas? This is critical as I have over 14,000 documents and even the open, click, open, click will just take too long.
strDoc = Dir(Path & "*.Doc")
Do While strDoc <> ""
and have tried various combinations to complete the loop, but it just isn't working. Any ideas? This is critical as I have over 14,000 documents and even the open, click, open, click will just take too long.
ASKER
Here is what I have so far and the error I am getting back.
Sub SaveLast24()
Dim Path As String
Dim strDoc As String
Dim Doc As Document
Path = "c:\ahg_files_orig\test_gr oup"
strDoc = Dir(Path & "*.rtf")
Do While Doc <> ""
Set Doc = Documents.Open(FileName:=P ath & Doc)
Selection.EndKey Unit:=wdStory
For i = 1 To 23
Application.Browser.Previo us
Next i
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Delete
ActiveDocument.Save
Doc.Close
strDoc = Dir
Loop
End Sub
Error when running:
Run-time error 91
Object variable or With block variable not wet
Sub SaveLast24()
Dim Path As String
Dim strDoc As String
Dim Doc As Document
Path = "c:\ahg_files_orig\test_gr
strDoc = Dir(Path & "*.rtf")
Do While Doc <> ""
Set Doc = Documents.Open(FileName:=P
Selection.EndKey Unit:=wdStory
For i = 1 To 23
Application.Browser.Previo
Next i
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Delete
ActiveDocument.Save
Doc.Close
strDoc = Dir
Loop
End Sub
Error when running:
Run-time error 91
Object variable or With block variable not wet
ASKER
Bill Mercer:
Thank you for the guidance on creating this VB Macro, with a little tweaking and adding in a loop control it is humming right along. Now all I have to do is convert all the documents to use arial instead of the awful font that it is defaulted with.
Again I really appreciate the help and the stellar job!!!
THANK YOU!!!!
Shon
Thank you for the guidance on creating this VB Macro, with a little tweaking and adding in a loop control it is humming right along. Now all I have to do is convert all the documents to use arial instead of the awful font that it is defaulted with.
Again I really appreciate the help and the stellar job!!!
THANK YOU!!!!
Shon
Glad to hear it worked for you. Thanks.