I am trying to create a word document using VB6 and need to use columns
breaks but cant seem to find out why my code doesnt work the way it
should. It creates a column break but when i trying to go back to one
column to finish off the document it takes the second column and puts
it on the next page. Any ideas on what i may be doing wrong with the
code below?


With surveyApp.Selection


surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3D.Start).InsertBreak
Type:=3DwdSectionBreakContinuous
.Start =3D .Start + 1
With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3DsurveyApp.ActiveDocument.=AD=AD=AD=ADContent.End).PageSetup.Text=ADC=
=ADo=ADl=ADumns



.SetCount numcolumns:=3D2
.EvenlySpaced =3D True
.LineBetween =3D False
.Width =3D InchesToPoints(2.75)
.Spacing =3D InchesToPoints(0.5)
End With


Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset
Dim cmd As New ADODB.Command
cmd.ActiveConnection =3D conn


rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
adLockOptimistic


If rs3.EOF Then
.TypeText Text:=3D"None indicated"
.TypeParagraph
.TypeParagraph
rs3.Close
Else


'Setup for mutliple columns
Dim currentline As Integer
Dim group(500) As Integer 'this is the line that the group starts
on
Dim currentgroup As Integer
Dim lines(500) As Integer 'this is the current group for a given
line


currentline =3D 0
currentgroup =3D 0


While Not rs3.EOF
currentgroup =3D currentgroup + 1
group(currentgroup) =3D currentline
lines(currentline) =3D currentgroup
.TypeText Text:=3Drs3("groupname")
.TypeText vbTab
.TypeText Text:=3Drs3("problem")
.TypeParagraph
currentline =3D currentline + 1


rs4.Open "SELECT * From problemoccurred WHERE groupname =3D '" &
rs3!GroupName & "' order by problemoccurred desc", conn, adOpenDynamic,



adLockOptimistic


While Not rs4.EOF
.TypeText Text:=3Drs4("problemdesc")
lines(currentline) =3D currentgroup
.TypeText vbTab
.TypeText Text:=3Drs4("problemoccurred")
.TypeParagraph
currentline =3D currentline + 1
' .MoveRight unit:=3DwdCell
' .MoveRight unit:=3DwdCell
rs4.MoveNext
Wend
rs4.Close
rs3.MoveNext
Wend
rs3.Close


If currentgroup > 1 Then
Dim gobackto As Integer
If lines(currentline / 2) =3D 1 Then
gobackto =3D group(2)
Else


gobackto =3D group(lines(currentline / 2))


End If


.MoveUp unit:=3DwdLine, Count:=3D(currentline - gobackto)
.InsertBreak wdColumnBreak


End If


.EndKey wdStory
With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3D.End).PageSetup.TextColum=AD=AD=AD=ADns
.SetCount numcolumns:=3D1
.EvenlySpaced =3D True
.LineBetween =3D False=20
End With=20


End If=20
End With

RE: Column Break Help by Chuck

Chuck
Wed Apr 06 12:23:02 CDT 2005

At the end of the code you're posting you are selecting the entire document
before you set the column count to 1 - so the colum break becomes in effect a
page break (because there's only one column).

You need to set your range to where you want to go back to one column -- if
that's the end of the document, it's simple:

With ActiveDocument.Range
.Start = ActiveDocument.Range.End
.Start = ActiveDocument.Range.End
.InsertBreak Type:=wdSectionBreakContinuous
With .PageSetup.TextColumns
.SetCount 1
.EvenlySpaced = True
.LineBetween = False
End With
End With



With surveyApp.ActiveDocument.Range­­­­(Start:=.Start, End:=.End)

"pkruti@hotmail.com" wrote:

> I am trying to create a word document using VB6 and need to use columns
> breaks but cant seem to find out why my code doesnt work the way it
> should. It creates a column break but when i trying to go back to one
> column to finish off the document it takes the second column and puts
> it on the next page. Any ideas on what i may be doing wrong with the
> code below?
>
>
> With surveyApp.Selection
>
>
> surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=.Start).InsertBreak
> Type:=wdSectionBreakContinuous
> ..Start = .Start + 1
> With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=surveyApp.ActiveDocument.­­­­Content.End).PageSetup.Text­C­o­l­umns
>
>
>
> ..SetCount numcolumns:=2
> ..EvenlySpaced = True
> ..LineBetween = False
> ..Width = InchesToPoints(2.75)
> ..Spacing = InchesToPoints(0.5)
> End With
>
>
> Dim rs3 As New ADODB.Recordset
> Dim rs4 As New ADODB.Recordset
> Dim cmd As New ADODB.Command
> cmd.ActiveConnection = conn
>
>
> rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
> adLockOptimistic
>
>
> If rs3.EOF Then
> .TypeText Text:="None indicated"
> .TypeParagraph
> .TypeParagraph
> rs3.Close
> Else
>
>
> 'Setup for mutliple columns
> Dim currentline As Integer
> Dim group(500) As Integer 'this is the line that the group starts
> on
> Dim currentgroup As Integer
> Dim lines(500) As Integer 'this is the current group for a given
> line
>
>
> currentline = 0
> currentgroup = 0
>
>
> While Not rs3.EOF
> currentgroup = currentgroup + 1
> group(currentgroup) = currentline
> lines(currentline) = currentgroup
> .TypeText Text:=rs3("groupname")
> .TypeText vbTab
> .TypeText Text:=rs3("problem")
> .TypeParagraph
> currentline = currentline + 1
>
>
> rs4.Open "SELECT * From problemoccurred WHERE groupname = '" &
> rs3!GroupName & "' order by problemoccurred desc", conn, adOpenDynamic,
>
>
>
> adLockOptimistic
>
>
> While Not rs4.EOF
> .TypeText Text:=rs4("problemdesc")
> lines(currentline) = currentgroup
> .TypeText vbTab
> .TypeText Text:=rs4("problemoccurred")
> .TypeParagraph
> currentline = currentline + 1
> ' .MoveRight unit:=wdCell
> ' .MoveRight unit:=wdCell
> rs4.MoveNext
> Wend
> rs4.Close
> rs3.MoveNext
> Wend
> rs3.Close
>
>
> If currentgroup > 1 Then
> Dim gobackto As Integer
> If lines(currentline / 2) = 1 Then
> gobackto = group(2)
> Else
>
>
> gobackto = group(lines(currentline / 2))
>
>
> End If
>
>
> .MoveUp unit:=wdLine, Count:=(currentline - gobackto)
> .InsertBreak wdColumnBreak
>
>
> End If
>
>
> ..EndKey wdStory
> With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=.End).PageSetup.TextColum­­­­ns
> ..SetCount numcolumns:=1
> ..EvenlySpaced = True
> ..LineBetween = False
> End With
>
>
> End If
> End With
>
>

RE: Column Break Help by Chuck

Chuck
Wed Apr 06 12:23:04 CDT 2005

OOPS

Code should have read:

With ActiveDocument.Range
.Start = ActiveDocument.Range.End
.End = ActiveDocument.Range.End
.InsertBreak _
Type:=wdSectionBreakContinuous
With .PageSetup.TextColumns
.SetCount numcolumns:=1
.EvenlySpaced = True
.LineBetween = False
End With
End With


"pkruti@hotmail.com" wrote:

> I am trying to create a word document using VB6 and need to use columns
> breaks but cant seem to find out why my code doesnt work the way it
> should. It creates a column break but when i trying to go back to one
> column to finish off the document it takes the second column and puts
> it on the next page. Any ideas on what i may be doing wrong with the
> code below?
>
>
> With surveyApp.Selection
>
>
> surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=.Start).InsertBreak
> Type:=wdSectionBreakContinuous
> ..Start = .Start + 1
> With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=surveyApp.ActiveDocument.­­­­Content.End).PageSetup.Text­C­o­l­umns
>
>
>
> ..SetCount numcolumns:=2
> ..EvenlySpaced = True
> ..LineBetween = False
> ..Width = InchesToPoints(2.75)
> ..Spacing = InchesToPoints(0.5)
> End With
>
>
> Dim rs3 As New ADODB.Recordset
> Dim rs4 As New ADODB.Recordset
> Dim cmd As New ADODB.Command
> cmd.ActiveConnection = conn
>
>
> rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
> adLockOptimistic
>
>
> If rs3.EOF Then
> .TypeText Text:="None indicated"
> .TypeParagraph
> .TypeParagraph
> rs3.Close
> Else
>
>
> 'Setup for mutliple columns
> Dim currentline As Integer
> Dim group(500) As Integer 'this is the line that the group starts
> on
> Dim currentgroup As Integer
> Dim lines(500) As Integer 'this is the current group for a given
> line
>
>
> currentline = 0
> currentgroup = 0
>
>
> While Not rs3.EOF
> currentgroup = currentgroup + 1
> group(currentgroup) = currentline
> lines(currentline) = currentgroup
> .TypeText Text:=rs3("groupname")
> .TypeText vbTab
> .TypeText Text:=rs3("problem")
> .TypeParagraph
> currentline = currentline + 1
>
>
> rs4.Open "SELECT * From problemoccurred WHERE groupname = '" &
> rs3!GroupName & "' order by problemoccurred desc", conn, adOpenDynamic,
>
>
>
> adLockOptimistic
>
>
> While Not rs4.EOF
> .TypeText Text:=rs4("problemdesc")
> lines(currentline) = currentgroup
> .TypeText vbTab
> .TypeText Text:=rs4("problemoccurred")
> .TypeParagraph
> currentline = currentline + 1
> ' .MoveRight unit:=wdCell
> ' .MoveRight unit:=wdCell
> rs4.MoveNext
> Wend
> rs4.Close
> rs3.MoveNext
> Wend
> rs3.Close
>
>
> If currentgroup > 1 Then
> Dim gobackto As Integer
> If lines(currentline / 2) = 1 Then
> gobackto = group(2)
> Else
>
>
> gobackto = group(lines(currentline / 2))
>
>
> End If
>
>
> .MoveUp unit:=wdLine, Count:=(currentline - gobackto)
> .InsertBreak wdColumnBreak
>
>
> End If
>
>
> ..EndKey wdStory
> With surveyApp.ActiveDocument.Range­­­­(Start:=.Start,
> End:=.End).PageSetup.TextColum­­­­ns
> ..SetCount numcolumns:=1
> ..EvenlySpaced = True
> ..LineBetween = False
> End With
>
>
> End If
> End With
>
>

Re: Column Break Help by pkruti

pkruti
Wed Apr 06 13:20:56 CDT 2005

Thank you very much that helped alot.

kruti

Chuck wrote:
> OOPS
>
> Code should have read:
>
> With ActiveDocument.Range
> .Start =3D ActiveDocument.Range.End
> .End =3D ActiveDocument.Range.End
> .InsertBreak _
> Type:=3DwdSectionBreakContinuous
> With .PageSetup.TextColumns
> .SetCount numcolumns:=3D1
> .EvenlySpaced =3D True
> .LineBetween =3D False
> End With
> End With
>
>
> "pkruti@hotmail.com" wrote:
>
> > I am trying to create a word document using VB6 and need to use
columns
> > breaks but cant seem to find out why my code doesnt work the way it
> > should. It creates a column break but when i trying to go back to
one
> > column to finish off the document it takes the second column and
puts
> > it on the next page. Any ideas on what i may be doing wrong with
the
> > code below?
> >
> >
> > With surveyApp.Selection
> >
> >
> > surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
> > End:=3D.Start).InsertBreak
> > Type:=3DwdSectionBreakContinuous
> > ..Start =3D .Start + 1
> > With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
> >
End:=3DsurveyApp.ActiveDocument.=AD=AD=AD=ADContent.End).PageSetup.Text=ADC=
=ADo=ADl=ADumns
> >
> >
> >
> > ..SetCount numcolumns:=3D2
> > ..EvenlySpaced =3D True
> > ..LineBetween =3D False
> > ..Width =3D InchesToPoints(2.75)
> > ..Spacing =3D InchesToPoints(0.5)
> > End With
> >
> >
> > Dim rs3 As New ADODB.Recordset
> > Dim rs4 As New ADODB.Recordset
> > Dim cmd As New ADODB.Command
> > cmd.ActiveConnection =3D conn
> >
> >
> > rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
> > adLockOptimistic
> >
> >
> > If rs3.EOF Then
> > .TypeText Text:=3D"None indicated"
> > .TypeParagraph
> > .TypeParagraph
> > rs3.Close
> > Else
> >
> >
> > 'Setup for mutliple columns
> > Dim currentline As Integer
> > Dim group(500) As Integer 'this is the line that the group
starts
> > on
> > Dim currentgroup As Integer
> > Dim lines(500) As Integer 'this is the current group for a
given
> > line
> >
> >
> > currentline =3D 0
> > currentgroup =3D 0
> >
> >
> > While Not rs3.EOF
> > currentgroup =3D currentgroup + 1
> > group(currentgroup) =3D currentline
> > lines(currentline) =3D currentgroup
> > .TypeText Text:=3Drs3("groupname")
> > .TypeText vbTab
> > .TypeText Text:=3Drs3("problem")
> > .TypeParagraph
> > currentline =3D currentline + 1
> >
> >
> > rs4.Open "SELECT * From problemoccurred WHERE groupname =3D '" &
> > rs3!GroupName & "' order by problemoccurred desc", conn,
adOpenDynamic,
> >
> >
> >
> > adLockOptimistic
> >
> >
> > While Not rs4.EOF
> > .TypeText Text:=3Drs4("problemdesc")
> > lines(currentline) =3D currentgroup
> > .TypeText vbTab
> > .TypeText Text:=3Drs4("problemoccurred")
> > .TypeParagraph
> > currentline =3D currentline + 1
> > ' .MoveRight unit:=3DwdCell
> > ' .MoveRight unit:=3DwdCell
> > rs4.MoveNext
> > Wend
> > rs4.Close
> > rs3.MoveNext
> > Wend
> > rs3.Close
> >
> >
> > If currentgroup > 1 Then
> > Dim gobackto As Integer
> > If lines(currentline / 2) =3D 1 Then
> > gobackto =3D group(2)
> > Else
> >
> >
> > gobackto =3D group(lines(currentline / 2))
> >
> >
> > End If
> >
> >
> > .MoveUp unit:=3DwdLine, Count:=3D(currentline - gobackto)
> > .InsertBreak wdColumnBreak
> >
> >
> > End If
> >
> >
> > ..EndKey wdStory
> > With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
> > End:=3D.End).PageSetup.TextColum=AD=AD=AD=ADns
> > ..SetCount numcolumns:=3D1
> > ..EvenlySpaced =3D True
> > ..LineBetween =3D False
> > End With=20
> >=20
> >=20
> > End If=20
> > End With
> >=20
> >