converting frames to textboxes

B

bibikoff

Sorry for my English, I know it's very bad :)

I need a utility or macros that can convert all frames in document to
equivalent textboxes.

I will attempt to explain why this necessarily to me.
We are using Crystal Reports 8 for reporting. Sometimes users want to
export report in a word document and edit it. In this case Crystal
presents each element of the report as the frame. You will imagine
multi-page invoice with 1000 frames. Introducing changes in this
document (delete or add some positions) is practically impossible.

Frames suppose work with them only on one for time. I need multiple
selection. Texboxes allow this feature. I think they solve my problem.

PS: I know that textboxes doesn't have all frame's features. It
arranges me.

crossposted to microsoft.public.word.programming
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Sorry for my English, I know it's very bad :)

I need a utility or macros that can convert all frames in document to
equivalent textboxes.

I will attempt to explain why this necessarily to me.
We are using Crystal Reports 8 for reporting. Sometimes users want to
export report in a word document and edit it. In this case Crystal
presents each element of the report as the frame. You will imagine
multi-page invoice with 1000 frames. Introducing changes in this
document (delete or add some positions) is practically impossible.

Frames suppose work with them only on one for time. I need multiple
selection. Texboxes allow this feature. I think they solve my problem.

PS: I know that textboxes doesn't have all frame's features. It
arranges me.

Keep in mind that unless you have code to read all the frames properties,
the textboxes you generate will not reflect all the frames attributes (Such
as width, height, wrapping, etc.)
That being said, play around with this to get you started:

'_______________________________________
Sub FramesToTextboxes()

Dim frmParas As Frames
Dim rgeCurrent As Range


If ActiveDocument.Range.Frames.Count > 0 Then
Set frmParas = ActiveDocument.Range.Frames
Else
MsgBox "There are no frames to convert in this document."
Exit Sub
End If

Set rgeCurrent = Selection.Range

Application.ScreenUpdating = False

Do
With frmParas(1)
.Select
.Delete
End With
Selection.CreateTextbox
Loop While frmParas.Count > 0

rgeCurrent.Select

Application.ScreenRefresh
Application.ScreenUpdating = True

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

bibikoff

Jean-Guy, thanks!!!
I do it. Your code helps me very much.


This is my solution, for those who encountered the similar problems:


Sub FramesToTextboxes1()

Dim frmParas As Frames
Dim rgeCurrent As Range
Dim colFrameProps As Collection

If ActiveDocument.Range.Frames.Count > 0 Then
Set frmParas = ActiveDocument.Range.Frames
Else
MsgBox "There are no frames to convert in this document."
Exit Sub
End If

Set rgeCurrent = Selection.Range

Application.ScreenUpdating = False

Do

With frmParas(1)
Debug.Print .Range.Text

Set colFrameProps = New Collection
colFrameProps.Add .HorizontalPosition, "HorizontalPosition"
colFrameProps.Add .VerticalPosition, "VerticalPosition"
colFrameProps.Add .Height, "Height"
colFrameProps.Add .Width, "Width"

.Select
.Delete
End With

Selection.CreateTextbox
With Selection.ShapeRange(1)

.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage

.Left = colFrameProps("HorizontalPosition")
.Top = colFrameProps("VerticalPosition")
.Height = colFrameProps("Height")
.Width = colFrameProps("Width")

'delete margin
.TextFrame.MarginBottom = 0
.TextFrame.MarginTop = 0
.TextFrame.MarginLeft = 0
.TextFrame.MarginRight = 0

'hide border
.Line.Visible = msoFalse
.Fill.Visible = msoFalse

Set colFrameProps = Nothing
End With

DoEvents
Loop While frmParas.Count > 0

rgeCurrent.Select

Application.ScreenRefresh
Application.ScreenUpdating = True

End Sub






Jean-Guy Marcil пиÑал(а):
 

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