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 aFrame.Delete 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 shp.delete 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, pfeller
This conversation is currently closed to new comments.
We are experiencing the same problem. we used ot export reports from Crystal 8.5 to Word and they were easily edited now with all the text boxes and frames it is almost impossible. Did you find a way around this?
I found no loss of formatting in the Word document -- the frames are gone, formatting remains. But I'm not working with Crystal, so my initial document was built differently, I'm sure.
What I am experiencing is a loss of tables in the text frames (I have both frames and text frames). Is there any code that would check to see if the content of the text box is a table and if so, copy it out as is?
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Word Macro
Sub CleanUpExport()
For Each aFrame In ActiveDocument.Frames
aFrame.Delete
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
shp.delete
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,
pfeller