
07-08-2011, 08:22 AM
|
Novice
|
|
Join Date: Apr 2011
Posts: 27
|
|
Hi Pual,
Thanks for your reply.
Quote:
“Are the pictures formatted as 'in-line' or as 'square' etc? What are the 'figures' (eg are these graphics, captions for the pictures, something else)?”
|
Paul, the pictures & figures are formatted “in-line’. I have managed to delete them as I found a code on the web which I included as ‘Call’ to your code. It works except it does not delete the numbers and captions.
Code:
Sub DitchPictures(DocSrc)
Dim objPic As InlineShape
For Each objPic In ActiveDocument.InlineShapes
objPic.Delete
Next objPic
End Sub
Quote:
“Does the 'Design Requirements' portion of the document only ever comprise one Section? What do you want done with the 'Code and Standards' etc Sections that follow it?”
|
Paul, Yes it comprise of one group of section with sub sections (i.e. 4. 'Design Requirements', 4.1. XXXXXXXX, 4.2. XXXXXXX, 4.2.1. XXXXXXX, 8. 8.1, 8.2, 8.2.1, etc.)
Quote:
“What do you want done with the 'Code and Standards' etc Sections that follow it?”
|
I need all sections that say 'Design Requirements' as one separate file.
The section that follow are not required.
This 'Design Requirements' file is important. If this can be fixed the rest of the code is fine.
Quote:
“If the numbering issue is simply with the number assigned to the 'Design Requirements' heading and you're using Heading Styles for that, it should be possible for Word to tell that document to start the numbering from whatever number the 'Design Requirements' heading had in the source document. Coding for that would take a bit of working out, which I can't do right now as I'm travelling. I would also need to know what heading level is used for the 'Design Requirements' heading.”
|
Paul, Don’t bother, you can ignore this, I can live with the numbering.
Paul, I keep on searching the web, I found this code from Microsoft.com, which separates all sections and creates individual pages (see code below). Will this code help to separate only 'Design Requirements' by modifying it. I don’t mind if this code is an exclusive and not added to your previous code. But, it should be the same as your code that creates a output folder and creates files.
Code:
Sub BreakOnSection()
' Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection
'A mail merge document ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)
'Note: If a document does not end with a section break,
'substitute the following line of code for the one above:
'For I = 1 To ActiveDocument.Sections.Count
'Select and copy the section text to the clipboard.
ActiveDocument.Bookmarks("\Section").Range.Copy
'Create a new document to paste text from clipboard.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next section in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Quote:
“A minor error in the posted code - change:
With Content.Find
to
With .Content.Find”
|
I will change to “With .Content.Find”
I did try for an hour by playing around and entered this ‘With DocSrc.Content.Find’ it worked. Will this change anything in the code?
Thanks once again
FLDS
|