The document I had to remove text boxes from had extensive graphics within the boxes and around them. There were hundreds of them in the document. So far (I use that to qualify) we haven't found any problems with the removal of the text boxes and the placement of the text back into the document. There were also hundreds of tables in the thing. It was a seriously ugly piece of project manager graphic design and authorship. Fingers crossed. And Howard, most importantly, thanks for working out the limitations of the macro code - that helps immensely when trying to find out why things aren't working - which, lets face it, with MS, is most of our lives work... Warren. ________________________________ From: austechwriter-bounce@xxxxxxxxxxxxx [mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Howard Silcock Sent: Friday, 2 September 2011 14:18 To: austechwriter@xxxxxxxxxxxxx Subject: atw: Re: pdf converted to doc with text boxes containing content. Hi again, Neil I've had a further look at the macro you posted and realise that it has a whole lot of other problems. 1. It works by converting shapes to frames, then removing the frames, leaving just the text. However, you can only convert a shape to a frame if it supports attached text. The macro doesn't include any test to see whether the shape it's currently working on supports attached text or not, so if your document contains graphics, for example, the macro will just fail when it tries to process the corresponding shape. So, as I suggested earlier, the macro will almost certainly fail when some types of graphic are present, or inline text boxes. 2. If it succeeds in converting all the textbox shapes to frames, it then proceeds to delete ALL the frames in the document. This will include any other frames that may have already been there initially and not arisen from converting the textbox shapes. So in this case the macro may not fail, but could delete stuff it wasn't meant to. In other words, running the macro can have serious side effects! (In Word 97 and later frames have been replaced by text boxes, so it's less likely that there would be other frames around, but it's still a very dodgy approach.) 3. The macro falls into a basic trap that anyone who's tried to used a macro to delete elements of a collection, or convert them to something else, is likely to have encountered. As you loop through the collection deleting or converting items, you're changing the collection and the code may lose track of what's left to be deleted or converted. So the loop can stop before it's meant to. That's what happens with this code. In my sample document, I had three text boxes, carefully set up to be floating, and the code converted the first two to frames and then stopped converting. I realised it had lost count of where it was, because after the conversions the collection of shapes it was processing had got smaller. There are tricks to avoid this, but the author didn't use them (I used one in the macro I posted here - looping backwards from the last shape to the first). In summary, if you plan to use this macro, check that all your text boxes are floating, be careful of problems from graphics in the document or anything in frames, and, when the macro seems to have run successfully, check to see that all text boxes actually were processed. Howard On 2 September 2011 12:34, Neil Maloney <maloneyn@xxxxxxxxxxx<mailto:maloneyn@xxxxxxxxxxx>> wrote: Howard, Thanks, very useful and necessary feedback for anyone that wants to use the macro. I did a quick test after finding the macro on the net, and used a temporary document that had two text boxes (that were not inline) with a few text paragraphs around the boxes. I have my clients "trained" not to use text boxes (or other "float on text" objects) and rarely have to remove text boxes, etc. from draft documents received for formatting. Neil. On 2/09/2011 12:11 PM, Howard Silcock wrote: Neil I have some concerns about the macro you posted. If it works for Warren, well, that fixes the immediate need. But it didn't work on the test document I created. A problem arises if a text box is set inline, rather than floating. My test document had some text boxes of each type and the floating ones worked, but the others caused errors. (Actually, I mean the floating ones worked once the others had been removed - the presence of an inline one caused the whole macro to fail.) Also the macro loops through every shape in the document, regardless of whether they are textboxes or not, and attempts to carry out its steps. I guess in most cases if you had, say, graphics (which are also shapes), the macro would just fail when it attempted to process them too - I haven't yet tested that. Another point that I wasn't clear about is where the macro is supposed to put the text it retrieves from the text boxes. The only place that made much sense was to add it to the end of the document. This macro is designed to do that and seems to work, but may need more testing (use at your own risk): Sub GetTextFromTextboxes() Dim tb As Shape Dim s As String Dim i As Integer s = "" With ActiveDocument For i = .Shapes.Count To 1 Step -1 If .Shapes(i).Type = msoTextBox Then s = s & .Shapes(i).TextFrame.TextRange.Text .Shapes(i).Delete End If Next .Range.InsertAfter Text:=s End With End Sub Howard On 2 September 2011 09:41, Neil Maloney <maloneyn@xxxxxxxxxxx<mailto:maloneyn@xxxxxxxxxxx>> wrote: Warren, This does the trick, I have tested it: Sub RemoveTextbox() Dim MyBox As Shape For Each MyBox In ActiveDocument.Shapes With MyBox .Select .Line.Visible = msoFalse .ConvertToFrame End With Next MyBox Dim MyFrame As Frame For Each MyFrame In ActiveDocument.Frames MyFrame.Select MyFrame.Delete Next MyFrame End Sub Sourced from: http://groups.google.com/group/microsoft.public.word.docmanagement/browse_thread/thread/c74f8d7dca0cc56a/c0d953b51959621c?lnk=st&q=word+convert+text+boxes+to+frames#c0d953b51959621c And I got that link from: http://www.techtalkz.com/microsoft-office-word/189766-remove-text-boxes.html Neil. On 2/09/2011 9:29 AM, Lewington, Warren wrote: Hi all. Anyone have a macro that will remove content from text boxes in Word and paste it into the document or can point me to a macro repository where one exists? Warren Lewington Technical Writer | Control Systems Delivery | Communications & Control Systems | Asset Operations Group | RailCorp ************************************************** To view the austechwriter archives, go to www.freelists.org/archives/austechwriter<//www.freelists.org/archives/austechwriter> To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx<mailto:austechwriter-request@xxxxxxxxxxxxx> with "unsubscribe" in the Subject field (without quotes). To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go to www.freelists.org/list/austechwriter<//www.freelists.org/list/austechwriter> To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx<mailto:austechwriter-admins@xxxxxxxxxxxxx> ************************************************** ************************************************** To view the austechwriter archives, go to www.freelists.org/archives/austechwriter<//www.freelists.org/archives/austechwriter> To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx<mailto:austechwriter-request@xxxxxxxxxxxxx> with "unsubscribe" in the Subject field (without quotes). To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go to www.freelists.org/list/austechwriter<//www.freelists.org/list/austechwriter> To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx<mailto:austechwriter-admins@xxxxxxxxxxxxx> **************************************************