Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

SaveAs macro w/filename from pasted info in doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Laura - 21 Nov 2005 16:31 GMT
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
Doug Robbins - Word MVP - 21 Nov 2005 18:55 GMT
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.

Signature

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

>i have 60+ docs that need to burst into 4 docs each.  3rd row table at top
>of
[quoted text clipped - 23 lines]
>        SaveAsAOCELetter:=False
>    End Sub
Laura - 22 Nov 2005 15:08 GMT
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.

> 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
[quoted text clipped - 33 lines]
> >        SaveAsAOCELetter:=False
> >    End Sub
Doug Robbins - Word MVP - 22 Nov 2005 21:03 GMT
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

Signature

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

>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
[quoted text clipped - 57 lines]
>> >        SaveAsAOCELetter:=False
>> >    End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.