Move figures and tables to separate documents

P

periodic

Hi there. I have been put in charge for doing the final layout of a book on
about 800 pages. It has gotten me deeper than I thought into the world of
Word :)

Anyway I have been able to sort out most of the stuff with the help of some
books, internet and a small dose of VBA programming.

There is however a small clutch here. The book needs two end versions. One
with a nice layout, all pictures and tables where they should be and one
version for a publisher. However the publisher wants the book in double line
spacing and all tables and figures on separate documents with some references
in the the text about where the figure should go. The double line spacing
style I see no problem to fix since I have forced everyone writing to use my
template. But to move all the pictures and tables would be a tedious work to
do by hand. I started writing a macro using the goto function and thus
finding the tables/figures and using bookmarks to keep track of where I
where. I wish I could post the macro I wrote here but has been somehow been
lost :(

So my question is first, is there already some good function for doing this
or has someone written a macro for it? If there are non I have to do it
myself and then I wonder if you guys have any ideas if using goto is the best
way to find figures in word. Or if you have any other recommendations?

I did the same thing with LaTeX once by adding three lines to the top of my
source document. So I wonder how smooth word is to work with in these cases :)

Regards
Per
 
O

old man

Hi,

This turned out to be a bit more complicated because shapes are not in the
same layer as inline shapes and text. Anyway this works by converting all the
shapes to inline shapes and then cutting/pasting. I left in the code
(commented out) that converted the shapes back into inline shapes. The issue
with that is that inline shapes float so if you want to use the code you have
to fix the location which I think I have seen you do in this forum.... Also
check where I check for different kinds of shapes by using:

shape1.WrapFormat.Type = wdWrapInline

to see if it works.

Thanks to Chris Weber in this forum who showed how to convert shapes in a
previous post.

old man


Sub c1()
Dim d1 As Document
Dim origdocument As Document
Dim table1 As Table
Dim range1 As Range
Dim range2 As Range
Dim shape1 As Shape
Dim inlineshape1 As InlineShape

On Error GoTo out1
Set origdocument = ActiveDocument

Set d1 = Documents.Add
Set range2 = d1.Range
origdocument.Activate

'do all tables
For Each table1 In ActiveDocument.Tables
Set range1 = table1.Range
range1.Cut
d1.Activate
' range2.Start = d1.Content.End
Set range2 = ActiveDocument.Range
range2.Collapse wdCollapseEnd

range2.Paste

Selection.EndKey unit:=wdStory
Selection.TypeText vbCrLf

origdocument.Activate

Next

'do inlineshapes
For Each inlineshape1 In ActiveDocument.InlineShapes
Set range1 = inlineshape1.Range
range1.Cut
d1.Activate
' range2.Start = d1.Content.End
Set range2 = ActiveDocument.Range
range2.Collapse wdCollapseEnd

range2.Paste

Selection.EndKey unit:=wdStory
Selection.TypeText vbCrLf

origdocument.Activate

Next

'do shapes - convert to inlineshape
For Each shape1 In ActiveDocument.Shapes

On Error Resume Next

shape1.ConvertToInlineShape
If Err.Number <> 0 Then
shape1.WrapFormat.Type = wdWrapInline
shape1.Anchor.Paragraphs(1).Alignment = wdAlignParagraphCenter
End If

Next

'reset err handling
On Error GoTo out1

'now copy to target and convert back to shape
For Each inlineshape1 In ActiveDocument.InlineShapes
Set range1 = inlineshape1.Range
range1.Cut
d1.Activate
' range2.Start = d1.Content.End
Set range2 = ActiveDocument.Range
range2.Collapse wdCollapseEnd

range2.Paste

'Selection.WholeStory
' Selection.Range.InlineShapes(1).ConvertToShape

Selection.EndKey unit:=wdStory
Selection.TypeText vbCrLf

origdocument.Activate

Next

Exit Sub

out1:

MsgBox "err - " & Err.Description
End Sub



old man
 
P

periodic

Thanks! however I am in luck here. I have made sure all pictures are inline
shapes and I have some macros checking that they are before I have to move
them. Your code will be used. Not directly but bits and pieces will be used.
 

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