Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion


Word Macro

By byron.gough ·
When exporting a crystal report as a Word document, it is next to impossible to edit the new document because all text is placed in frames. I found the following macro that would delete the frames:

Sub CleanUpExport()
For Each aFrame In ActiveDocument.Frames
Next aFrame
End Sub

This macro deletes the frames no problem. Unfortunately, it also deletes all the formatting and the text all becomes left aligned. Has anyone created a macro that could be used to delete the frames AND retain the position/formatting of the text?

I found another macro that seems capable of this but only if the document has text boxes, not frames. I tried to modify this to address my situation but I don't know enough vba.

Sub RemoveTextBox2()
Dim shp As Shape
Dim oRngAnchor As Range
Dim sString As String

For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then
' copy text to string, without last paragraph mark
sString = Left(shp.TextFrame.TextRange.Text, _
shp.TextFrame.TextRange.Characters.Count - 1)
If Len(sString) > 0 Then
' set the range to insert the text
Set oRngAnchor = shp.Anchor.Paragraphs(1).Range
' insert the textbox text before the range object
oRngAnchor.InsertBefore _
"Textbox start << " & sString & " >> Textbox end"
End If
End If
Next shp
End Sub

I have tried exporting to a number of formats but the only one that even comes close to allowing some editing is Excel. It is just not very nice looking. Any ideas? Thanks for your time,

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums