atw: Re: pdf converted to doc with text boxes containing content.

  • From: Neil Maloney <maloneyn@xxxxxxxxxxx>
  • To: austechwriter@xxxxxxxxxxxxx
  • Date: Fri, 02 Sep 2011 12:34:31 +1000

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> 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 To unsubscribe, send a message to 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 To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx **************************************************

************************************************** To view the austechwriter archives, go to www.freelists.org/archives/austechwriter To unsubscribe, send a message to 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 To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx **************************************************

Other related posts: