SaveAs macro w/filename from pasted info in doc

L

Laura

i have 60+ docs that need to burst into 4 docs each. 3rd row table at top of
original doc contains app name that i would like to use in filename (ex,
EssBase). would like to number docs...essbase1, essbase2, essbase3,
essbase4..but don't know to incorporate this into my code. docs have never
been saved. part of current code is as follows...

....
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ActiveDocument.SaveAs FileName:="ADS06SPRINT 1.doc", FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
 
D

Doug Robbins - Word MVP

What is the criteria for where the documents are split? does each one
contain 4 pages and you want to create a separate document for each page? or
do you want to create four copies of the same document, each with a
different file name?

In which cell in the 3rd row of the table is the app name?

It's not difficult to do what you want, just need to know exactly what it
is.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Laura

i wish it was as simple as a page split. there are 4 sections of each
document (app security, change mgmt, bu&r and interfaces) plus some
"overview" information. the overview info is at the top and should be
included on all subsequent docs. to make it more difficult entire doc is
"normal" w/no special formatting.

my thought process was:
find "Application Security", bold, font size 14...everything above is
"overview"
find "Change Management"bold, font size 14...everything above is App
Security...

2 other sections "Backup & Recovery" and "Interfaces" unfortunately are not
consistently "3rd" and "4th" so i'm assuming I will have to split this out
manually.

filenames can be incremental "save/as" (1,2,3,4) and omit the app name in
the table. it's already in the doc title.
 
D

Doug Robbins - Word MVP

You could make use of the information in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

to insert a Section Break before each of your headings and then use a macro
to split the document based on the sections 2 through 5, incorporating the
overview info (form Section 1) in each of the documents so created. Some of
the code you would need for the splitting is in the following:

' splitter Macro

' Macro created by Doug Robbins to save each letter created by a mailmerge
as a separate file.

Dim i As Long, Source as Document, Target as Document, Letter as Range
Set Source = ActiveDocument
For i = 1 to Source.Sections.Count
Set Letter = Source.Sections(i).Range
Letter.End=Letter.End-1
Set Target = Documents.Add
Target.Range=Letter
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top